Database administration is a crucial aspect of IT operations and it’s often a difficult one. Using a managed database solution is a good idea to avoid headaches while maintaining your application availability. A managed database service worth considering is AWS Aurora Serverless v2, recently announced at re:Invent 2020.
Compared to a traditional database which is provisioned on servers, a serverless database decouples the notions of capacity from servers. You can simply specify the capacity you want, without knowing exactly what is the underlying hardware. Aurora uses a router fleet to transparently redirect the incoming requests to a pool of resources. The advantage of this model is that it becomes possible to scale up the database instance simply by doing a swap from a warm pool of instances.
In a traditional provisioned model, the database storage is typically local to the instance to increase performance. In the serverless model, the database storage has to be separated from the compute, to be able to swap compute instances as needed. AWS uses a distributed storage model where it stores 6 copies of the data in 3 availability zones for high availability. Distributed storage is actually extremely hard to do well. Without going in too much details, AWS Aurora uses a quorum model with 4 writes and 3 reads, meaning a write is acknowledged after 4 copies after been written. This ensures that performance is maintained even if a node is slow. The AWS provisioned Aurora also uses the distributed storage model.
Aurora Serverless v1
Aurora Serverless v1 was the first release of the serverless database model and became generally available in August 2018. It is compatible with both MySQL and PostgreSQL. To use a serverless database, you simply specify the minimum and maximum ACU (Aurora Capacity Unit), which represents the compute and memory available to the node. Based on your usage, Aurora is able to scale up and down to meet the incoming demand.
Scaling a database up or down is actually a complex operation on a provisioned instance. You have to launch a read replica, redirect traffic to the new instance, and then terminate the initial instance. Having a managed service that can do it automatically for you is a game changer for a lot of workloads. On top of that, if you have a spiky usage, you only have to pay for the spike usage as opposed to deploying a much larger provisioned instance all the time. The savings can also add up.
Some of the caveats of the service was the time required to performs scale ups. It could take up to 50 seconds, which can be problematic. Also, the ACUs would be doubled or halved at every scale up or down, so you might end up with too much capacity (but still less than a fully provisioned instance).
Aurora Serverless v2
AWS just announced the second version of Aurora Serverless at re:Invent 2020 to address these challenges. The new version should be able to instantly scale to hundreds of thousands of transactions in a fraction of a second. Also, the ACUs can now be scaled up incrementally, avoiding the required doubles / halves of Aurora serverless v1.
Serverless v2 should also be able to have multi-AZ support, global database, read replicas, backtrack, and parallel query. These are all features that are available in the provisioned AWS Aurora database, but were not available in Serverless v1. Some of these features are not yet available in the preview, but should be coming soon.
Worth noting, AWS Aurora Serverless v2 is only available on MySQL, but PostgreSQL support is planned for the first half of 2021.
Advantages of AWS Aurora Serverless
Let’s quickly review the advantages of using a serverless solution like AWS Aurora.
Having a database that automatically scales (almost instantly) to changes in demand is a enormous advantage. You don’t have to predict what the load will be, and you can’t be wrong. With a traditional provisioned model, if you predict too low, your infrastructure slows down, if you predict too high, you end up paying for unused capacity.
I think this is in line with a more general shift towards event-driven, quickly scalable infrastructure. With services like Lambda and Fargate, you can build a compute infrastructure that automatically adjust to what you need.
Easy of Maintenance
Not having to manage the infrastructure, take backups, install software is a clear advantage. This applies to any managed service, such as AWS Aurora, but it is even more important for a database service. There are few companies that can build and manage a database system with distributed storage over 3 availability zones. With such a service, you can focus on building the next great thing, as opposed to constantly managing and monitoring infrastructure.
When comparing costs, Aurora is going to be more expensive than a traditional MySQL provisioned on the same hardware, but that’s expected. The real cost savings comes from the fact that the infrastructure scales up or down to adjust to the load. For a company having spikes in traffic, this can probably mean having 90% cost savings vs provisioned, because most of the time, the provisioned infrastructure would have been mostly idled.
Let’s examine some use cases that could benefit from a serverless database.
To provision a database, you have to forecast the number of transactions the database has to be able to handle. If your workloads are unpredictable, or if you don’t have historical data, this can be very challenging. Having a serverless database to handle these unpredictable workload is a perfect choice.
Developing / Testing Environment
When developing applications, the testing environment is used during normal business hours, but is idle otherwise. Having a database that can scale up during the day, and scales down during non-business hours can definitely save costs as opposed to just using a provisioned instance all the time.
Intermittent Traffic Spikes
An application having intermittent traffic spikes (e.g. retail website) can also benefit from having a database service that can transparently handle those spikes. Otherwise, the retailer would have to provision a large infrastructure or risk losing sales.
Startups – Quick time to market
Startups can also benefit from having a managed database service that won’t cost them a lot while developing their application, will be easy to deploy and maintain, and can adjust to ongoing spikes as their application grows.
This was an overview of AWS Aurora Serverless, including how the serverless architecture works for a database, the advantages of using it, and some common use cases.
We also discussed the changes for Serverless v2, including instant scale ups, incremental ACUs adjustments, multi-AZ support, global database, read replicas, backtrack, and parallel query.
AWS Aurora Serverless v2 is currently in preview, so you can give it a try. This is likely to be a serious option for a lot of database workloads.