Optimizing Database Performance and Costs: Harnessing the Potential of Aurora Serverless

Shubham Gupta
Ula Engineering
Published in
6 min readMay 13, 2023

--

As the popularity of cloud computing continues to soar, businesses are increasingly seeking ways to optimize their database performance while minimizing costs. At ULA, we faced a similar challenge as our MySQL services and the associated RDS MySQL bill grew continuously.

During our research, we discovered that leveraging Amazon Aurora Serverless was one of the most effective approaches to address this issue. However, due to its relative novelty, we initially hesitated to utilize it in a production environment. To make an informed decision, we delved into a comprehensive exploration of its performance and cost implications. After conducting thorough analyses and using Aurora Serverless in various environments, including production, for several months, we came to the realization that using Aurora Serverless v2 necessitates careful consideration. While it can indeed lead to cost savings, it may also result in exponential increases in expenses if not implemented judiciously.

We dedicated a significant amount of time to uncovering these insights, and I’m excited to share our learnings here. In this article, we will delve into how I managed to reduce MySQL costs by up to 25% using Aurora Serverless. We’ll also explore when and where to leverage this technology to maximize savings, as well as where to exercise caution to avoid accruing excessive charges. So let’s take a deep dive into the realm of serverless computing.

But first, let’s understand what Amazon Aurora Serverless is?

Amazon Aurora Serverless is a serverless database service that offers a fully managed and autoscaling database, eliminating the need for provisioning or managing database servers. It is built upon Amazon Aurora, a cloud-based relational database that is compatible with MySQL and PostgreSQL.

Aurora Serverless operates by automatically scaling your database up or down based on the demands of your application. During periods of inactivity, Aurora Serverless scales your database down to zero capacity, ensuring you won’t incur any charges for unused database resources. As soon as your application requires database access, Aurora Serverless swiftly scales up your database to meet the demand.

To delve deeper into the specifics of Aurora Serverless, you can read more about it here: https://aws.amazon.com/rds/aurora/serverless/

Now, let’s discuss our savings strategy

I work with mid-sized B2B e-commerce company where our online store heavily relies on the MySQL database. As our website traffic increased, we encountered performance issues, especially during peak periods like flash sales. Recognizing the need to upgrade our database infrastructure, we were concerned about the associated costs. Additionally, the cost of RDS was rising due to the inclusion of new services in our infrastructure to support the increased traffic.

After conducting research, we decided to experiment with Aurora Serverless. We were attracted to the idea of paying only for the required resources and the capability to automatically scale based on demand. Moreover, the advanced features such as automated backups and high availability caught our attention.

To begin, we created an Aurora Serverless cluster and migrated our MySQL database onto it. Initially, we configured the minimum number of Aurora Capacity Units (ACUs) to 2 and the maximum to 32. This ensured that we paid for a minimum of 2 ACUs, while allowing the database to scale up to 32 ACUs during peak traffic.

We immediately observed a significant improvement in performance, particularly during peak traffic periods. Furthermore, we realised significant cost savings as we were no longer paying for idle instances. In our previous database setup, we incurred expenses for a fixed number of database instances irrespective of the actual usage, and we relied on over-provisioning resources to handle occasional spikes. By implementing Aurora Serverless, we learned to strike a balance and selectively utilize it, resulting in cost savings of up to 25% in the areas where we implemented it.

Pros

  1. Automatic scaling: Aurora Serverless v2 automatically scales your database up or down based on your application’s needs. This means that you don’t have to worry about managing database capacity yourself.
  2. Performance: Aurora Serverless v2 provides comparable performance to MySQL in most cases, with only a slight delay of approximately 100 to 200 milliseconds during scale-up operations. However, this delay lasts for only 1–2 seconds before returning to optimal performance. The scalability of Aurora Serverless allows for rapid capacity expansion, providing additional resources to serve customers without waiting for auto-scaling, which typically takes 8–10 minutes.
  3. Granular Billing: Aurora Serverless charges at the second level, allowing for more precise cost calculations. You pay only for the exact duration of resource usage, providing potential cost savings.
  4. Simplified Configuration and Management: Compared to traditional database setups, Aurora Serverless requires less manual configuration and management. The automated scaling capabilities alleviate the need for manual adjustments and ensure efficient resource allocation.
  5. Cost Savings: Aurora Serverless can save money for applications with variable usage patterns. By automatically scaling up or down based on demand, you avoid over-provisioning resources during low-traffic periods, resulting in potential cost reductions.
  6. High Scalability: Aurora Serverless is highly scalable, enabling your application to handle increasing workloads without manual intervention. This scalability ensures that your database can accommodate spikes in traffic or sudden growth in user activity.

Lessons learned

  1. Utilize Aurora Serverless primarily in areas with anticipated variable workloads.
  2. Deploy it in scenarios where workloads are unpredictable.
  3. Consider using Aurora Serverless for development and staging environments. Cost savings can be achieved during night hours and variable working hours. In these environments, where workload fluctuations are expected, resources can be procured only when needed.
  4. Exercise caution when considering the reduction of capacity to zero in production environments. Aurora Serverless takes a few seconds to reprovision compute capacity, which can result in a poor user experience during that timeframe. This setting is not recommended for production environments where low latency is a primary concern.
  5. Avoid using Aurora Serverless in continuous high workload situations, as it can lead to significantly higher costs. This will be further discussed in the cost considerations section.
  6. Take advantage of AWS’s capability to mix RDS Aurora provisioned instances and Aurora Serverless configurations. This mixed configuration approach is beneficial for applications with different patterns of read and write operations, ensuring uneven scalability, improved customer experience, and cost savings.
  7. Regularly monitor costs and usage patterns to optimize efficiency.
  8. While Aurora Serverless allows for minimum ACU values as low as 0.5 and maximum values up to 128, careful consideration is required when determining the appropriate configuration. Set the minimum ACU close to the continuous utilization level to maintain consistent performance. Serverless behavior dynamically adjusts ACU allocation based on various factors, such as available quota and traffic patterns. It may procure more ACUs than required for specific requests. To save costs, it is recommended to cap the ACU at an optimal level that satisfies customer needs while avoiding unnecessary resource provisioning.

Now let’s talk about cost

To be honest, the cost of Aurora Serverless v2 can initially appear high. For instance, when comparing the cost of serving constant traffic in the Asia Pacific (Singapore) region, an r5.large RDS instance with 16 GiB of memory priced at $0.35 per hour would be equivalent to 8 ACUs (8 * $0.20 = $1.6 per hour) at the time of publication. In this scenario, Aurora Serverless would be more than four times more expensive. Even if we consider Serverless v1, which costs around $0.8 per hour, it would still be approximately twice as expensive as reserved instances.

However, it’s essential to consider the places where we tend to over-provision resources to handle sudden spikes and unexpected workloads. Most of the time, our databases are underutilized, with an average usage of only 20–25%, except during high traffic periods. Additionally, if the CPU utilization drops below 10% during non-peak hours, it results in a wastage of resources. Taking these variabilities into account, implementing Aurora Serverless in strategic areas can still lead to significant cost savings if carefully planned.

The AWS marketing strategy for Amazon Aurora Serverless v2 claims that you can save up to 90% of your database cost compared to the cost of provisioning capacity for peak load. This is a bold claim, but if you factor in the amount of over-provisioning that goes on, especially if you include multi-tenant workloads, there definitely are some major cost savings possible here. If you’re running a fairly steady workload, then you have some calculations to do.

While Aurora is indeed an option worth considering, it’s crucial to thoroughly evaluate the advantages, limitations, and cost implications compared to traditional RDS. This evaluation will help you make the best decision for your company’s specific needs.

Final Thoughts

In conclusion, Aurora Serverless v2 offers compelling benefits such as improved performance, granular billing, simplified management, scalability, and potential cost savings. While the claimed 90% cost savings may not be achievable in all cases, careful evaluation of workload patterns and resource utilization can result in significant cost reductions. By strategically implementing Aurora Serverless and considering its advantages, limitations, and cost implications, businesses can optimize their database infrastructure and make informed decisions that align with their specific needs.

--

--