AWS Aurora Serverless

  • Topics

What Is AWS Aurora Serverless? 

Amazon Aurora is a relational database engine provided by Amazon Web Services (AWS), which is fully compatible with the open source MySQL and PostgreSQL databases. This means that code, applications, and drivers used by existing MySQL or PostgreSQL databases can be used in Aurora without changes. However, Aurora is a proprietary system and is not actually based on either open source database engine.

You can manage an Aurora database via Amazon Relational Database Service (RDS). In this case, RDS will handle provisioning, patching, backup, restore, and other tasks. However, RDS is not serverless, meaning that you still need to manually provision a computer instance for your database.

Aurora Serverless is an on-demand version of Amazon Aurora with auto-scaling capabilities. With Aurora Serverless, administrators don’t manage database instances at all. The database is managed as one instance that grows or shrinks according to requirements. You configure the required computing capacity via Aurora Capacity Units (ACUs), which are a combination of virtual CPUs and memory. Aurora Serverless lets you define minimum and maximum ACUs, and automatically scales compute capacity up or down within those limits.

Should You Use Amazon RDS or Aurora Serverless?

There are several considerations when choosing a relational database engine:

Compatibility

  • Aurora Serverless only works with PostgreSQL and MySQL. 
  • Amazon RDS also works with Oracle, MariaDB, and SQL Server. 

Capacity

  • Aurora Serverless is suitable for applications that don’t have to serve frequent traffic—for example, testing and development environments. While it allows cutting capacity to zero during idle periods, this option is less suited to production environments because adjusting the compute capacity can take time, impacting the end-user experience. 
  • Amazon RDS is better suited for production environments with regular traffic.

Flexibility

  • Aurora Serverless supports applications with sharp, unpredictable usage spikes. It enables fast, automatic configuration of the databases to decrease and increase capacity. 
  • Amazon RDS is better for applications with consistent usage because adjusting capacity is more time-consuming. 

Reserved Instances

  • Aurora Serverless doesn’t support reserved instances. 
  • Amazon RDS allows you to deploy reserved instances to lower costs by 30-60%, depending on the commitment period and instance type. 

Cost

  • Aurora Serverless is often the better option for certain applications because it automatically scales down when demand decreases. However, it can cost more if used for the wrong use case. 
  • Amazon RDS may be more cost-effective for some AWS use cases.

You should certainly consider Aurora Serverless, especially for non-production environments and applications with low or irregular traffic. However, evaluating the limitations, benefits, and costs compared to RDS is important to make the right choice for your organization. 

Aurora Serverless Features and Capabilities: v1 and v2 

Amazon Aurora Serverless v2 was released in April 2022. In the original Aurora v1, the query layer was provisioned manually. Users could choose an instance size for the database and instances for secondary read replicas, but after the initial deployment, the database would not scale automatically. In addition, Aurora v1 did not have multi-region replication.

Amazon Aurora Serverless v2 was designed to provide full autoscaling. It can monitor usage and automatically adapt database capacity to actual application loads. This means that as an application’s loads grow, the database grows seamlessly to provide additional capacity without manual configuration. If loads suddenly decrease, for example in applications with spikes in demand, the database scales down to conserve costs. 

Autoscaling is limited to vertical scalability (increasing and decreasing instance size), but v2 also introduces support for horizontal scaling.

The new capabilities introduced in v2 can be summarized as follows:

  • Simpler capacity management: no need to plan database instance sizes and resize the database when application demand changes, except for a one-time definition of minimum and maximum capacity. 
  • Faster scaling to accommodate spikes in demand: automated scaling for both compute and memory resources, with no downtime and no disruption to database transactions. Scale-down latency is up to 15x faster by some accounts.
  • Horizontal scaling—in v2 you can perform horizontal scaling in addition to vertical scaling. This is easier to use than provisioned (non-serverless) Aurora clusters and enables more granular management compared to the scaling capabilities in v1. This builds on the following capabilities, which were previously only available in provisioned Aurora clusters:
    • Elastic instance scaling—Aurora Serverless v2 increases ACUs in increments of 0.5, while v1 could only scale by doubling ACUs (2, 4, 8, 16 … 256).
    • Reader DB instances—Aurora Serverless v2 lets you create reader DB instances to scale beyond a single Aurora instance. It supports up to 15 readers, each with up to 256 ACUs, which enables scaling up to tens of thousands of active connections.
    • Multi-AZ clusters—ability to distribute v2 Aurora instances across multiple Amazon Availability Zones (AZs). This ensures database continuity even if an entire Amazon AZ goes down.
    • Global databases—v2 lets you create read-only copies of the Aurora cluster in other AWS Regions to ensure the database is resilient to the failure of an entire Amazon region.
  • More Aurora features available in the serverless model—v1 did not support many features that were available in a provisioned Aurora database. v2 adds support for many of these features, including Identity and Access Management (IAM) and Performance Insights.
  • Combining serverless and provisioned instances—in v2 it is possible to create a single Aurora cluster with both a serverless instance and traditional provisioned instances. This makes it possible to combine Aurora Serverless v2 with existing Aurora clusters managed via RDS.
  • Use of RDS proxy for database connections—v1 provided a data API that is accessed by Lambda functions, handles connection pooling with the Aurora database, and routes requests. In v2, connections are routed via the Amazon RDS proxy and connection pooling needs to be managed by the database owner. More on this below.

Pricing in Aurora v2 

The cost of Aurora Serverless v2 appears expensive, and while it is possible to save costs on your database for peak loads, it is not a cost-effective option for everyone. 

Comparing Aurora Serverless v2 to v1

The price of Aurora capacity units (ACUs) in v2 ($0.12/hr) is twice that of those in v1 ACUs ($0.06/hr). Another major difference is that v2 has incremental ACUs, while v1 has instance doubling—for example, v2 allows you to scale to nine ACUs, whereas v1 only offers eight or 16. Still, 16 v1 ACUs will be cheaper than nine v2 ACUs ($0.96 compared to $1.08).

Another difference is the time to scale down—v1 usually takes several minutes. Given that you pay for capacity per second, this extra time means paying for extra capacity. Thus, v2 is more cost-effective for spiky, inconsistent workloads but can be expensive for consistently high traffic. 

Aurora v2 is more granular and offers savings compared to provisioned (i.e., always on) capacity. For example, running an Aurora v1 db.r5.4xlarge instance at $2.32 per hour will amount to $1,094.40 per month per instance. Still, you’d need to provision more instances to accommodate spikes—thus, it would cost over $2000 per month to support peak capacity.

How v2 ACUs save money

Aurora v2 doesn’t require this redundancy so that you can provision a single cluster. You’d need 64 ACUs to offer the same capacity as the db.r5.4xlarge instance. Running at full capacity would be expensive ($5,529.60 per month), but you won’t run at full capacity most of the time. 

On a typical day, you’ll run at peak capacity (100%) for two hours, moderate capacity (50%) for ten hours, and low capacity (10%) for twelve hours. The pricing calculation for one day would be as follows:

(64 x 2 x 1 + 64 x 9 x 0.4 + 64 x 12 x 0.1) x $0.12 = $52.224 per day. 

That’s $1566.72 per month, significantly cheaper than the $2,188.80 per month for the same capacity in v1. In short, the savingscome  from reducing over-provisioning. 

Multi-region replication

Aurora Serverless v2 supports Global Database for data recovery from any region. You can run DR clusters in other regions with half an ACU. v2 also lets you scale across multiple regions as needed. However, Amazon charges fees for data transfers. 

Connection Routing in Aurora v2: Amazon RDS Proxy

Aurora Serverless v2, database connections are managed via Amazon Relational Database Service Proxy, a database proxy for Amazon RDS. It is a highly available, fully managed service that helps secure applications and makes them more scalable and resilient.

Applications with a modern, serverless architecture often have many open connections to a database server. Some applications open and close these connections frequently and use up the database compute resources and memory. 

Amazon RDS Proxy enables applications to share database connections to improve their scalability and efficiency. RDS Proxy facilitates the management of database access privileges, credentials, and authentication, integrating with AWS services like Identity and Access Management (IAM) and Secrets Manager.

You can enable Amazon RDS Proxy for most applications without code changes. There is no need to configure or manage more infrastructure.

Critique of the Use of RDS Proxy in Aurora Serverless v2

Some experts argue that the switch from a Data API to RDS Proxy has major disadvantages. Aurora Serverless is often accessed by Lambda functions, which can scale up very quickly. If thousands of Lambda functions suddenly start hitting an Aurora database, they can overwhelm it.

In Aurora Serverless v1, Lambda functions would access a Data API, which would transparently create connections to the Aurora database, while managing connection pooling.

The Aurora Serverless v2, with the switch to the RDS Proxy, there are two possible downsides:

  • RDS Proxy is a managed service that has an additional cost of $0.12 per hour, in addition to the cost of Aurora and Lambda. 
  • Amazon RDS Proxy can only be associated with a single database instance.

Debug fast and move on.

  • Resolve issues 3x faster
  • Reduce error rate
  • Speed up development
No code, 5-minute set up
Start debugging free