sodcalculator

10 Tech How-To

Serverless SQL Database: Compute & Storage Allocation

Guide 10-47897 · Updated · Step by step

A serverless SQL database automatically allocates compute and storage by separating the two: compute is provisioned on-demand per query or per second of activity, while storage is billed based on the actual data volume you hold, with the system scaling both up and down without manual intervention. This means you pay only for the compute you use (often measured in compute seconds or request units) and the storage you occupy, rather than for a pre-provisioned server. Below, we break down the mechanics, the differences between major providers, and what this means for your workloads and costs.

Background: From Provisioned to Serverless

Traditional cloud databases require you to choose a fixed instance size (e.g., 2 vCPUs, 8 GB RAM) and pay for it 24/7, even if you only run a few queries a day. This leads to either over-provisioning (wasting money) or under-provisioning (slow performance during spikes). Serverless databases emerged to solve this by abstracting the server entirely: the provider manages capacity, automatically scaling compute resources in response to demand, and scaling to zero when idle. The first major example was Amazon Aurora Serverless (2018), followed by Azure SQL Database Serverless (2019) and Google Cloud Spanner Serverless (2020). Each has its own billing and scaling model, but the core idea is the same: you don’t own or manage a server, you just interact with a database endpoint.

How Compute Allocation Works

In a serverless SQL database, compute is allocated dynamically based on workload. Here’s how it typically works:

  • Auto-scaling: The database monitors metrics like CPU, memory, and concurrency. When a query comes in, the system allocates the necessary resources (vCPUs, memory) to execute it. If many queries arrive simultaneously, it scales up; when idle, it scales down, possibly to zero compute.
  • Billing unit: You are charged for compute based on a unit that combines time and capacity. For example, Azure SQL Database Serverless uses serverless compute billed per vCore-second, while Aurora Serverless v1 uses ACUs (Aurora Capacity Units), each roughly 2 GB memory with matching CPU and networking. Aurora Serverless v2 bills per ACU-second.
  • Auto-pause: Many serverless databases have a configurable auto-pause delay (e.g., 5, 10, or 60 minutes of inactivity). When paused, compute is released, and you only pay for storage. A new connection resumes the database automatically, but with a cold-start delay (typically a few seconds to a minute).
  • Concurrency and burst: Some systems allow burst capacity for short spikes, while others have a maximum limit that you set to control costs. For instance, Azure lets you define a minimum and maximum vCores; Aurora Serverless v2 lets you set a minimum and maximum ACUs.

The key is that compute is ephemeral and elastic. You don’t need to guess peak load; the system handles it, and you pay only for what you use.

How Storage Allocation Works

Storage in serverless SQL databases is usually decoupled from compute, meaning it lives on a separate, durable storage layer (like a distributed storage fabric). Here’s what you need to know:

  • Pay per GB-month: You are billed for the amount of data stored, typically in GB-months (e.g., $0.10 per GB-month). This includes the actual data, indexes, and transaction logs.
  • Automatic scaling: Storage grows automatically as you insert data, up to a maximum (e.g., 64 TB for Aurora, 4 TB for Azure SQL Serverless). You don’t need to provision storage in advance.
  • Replication: The storage layer is typically replicated across multiple availability zones (AZs) for durability, and this replication cost is included in the per-GB price. For example, Aurora stores six copies of data across three AZs, but you pay only for the logical size.
  • I/O operations: Some serverless databases charge separately for I/O requests (read/write operations). Aurora Serverless, for instance, bills for I/O per million requests. This is separate from storage capacity.

Because storage is independent, you can scale compute to zero while keeping your data intact, and you only pay for the storage used.

Comparison: Aurora Serverless vs. Azure SQL Serverless vs. Google Spanner

Let’s compare the three major serverless SQL offerings to highlight differences in allocation and billing:

  • Aurora Serverless (AWS): v1 scales in ACU increments (2 GB memory each) and can scale to zero with auto-pause. v2 scales per ACU-second, allowing finer granularity, but has a minimum of 0.5 ACU. Both support MySQL and PostgreSQL. Storage is shared with provisioned Aurora, billed per GB-month, with I/O charges.
  • Azure SQL Database Serverless: Scales in vCore increments (min 0.5 vCore, max up to 80 vCores). Auto-pause is configurable; when paused, you pay only for storage. Billing is per vCore-second, and storage is included in the per-GB price, with separate I/O charges.
  • Google Cloud Spanner Serverless: Spanner is a globally distributed database, and its serverless mode (called “Spanner Serverless”) actually uses a shared compute pool, so you pay for processing capacity in processing units (PUs) per second, not per instance. Storage is billed per GB-month, and you can scale PUs from 100 to 1000s. It does not scale to zero; there’s a minimum of 100 PUs.

The main takeaway: all separate compute and storage, but the billing granularity and scaling behavior differ. Aurora v2 and Azure offer per-second billing; Spanner uses PUs.

Cost Implications and How to Estimate

Serverless databases can save money for intermittent or unpredictable workloads, but they can be more expensive for steady, high-load workloads. Here’s what to consider when estimating cost:

  • Compute cost: Multiply the compute unit price by the total compute-seconds used. For example, if Azure charges $0.000012 per vCore-second and you use 10 vCore-seconds per day, that’s $0.00012/day. But if you run 100 vCores for 24/7, it’s $103.68/day (100*86400*0.000012).
  • Storage cost: Multiply GB-month price by average storage size. If you have 100 GB and $0.10/GB-month, that’s $10/month.
  • I/O costs: These can dominate for read/write-heavy workloads. Check your provider’s I/O pricing and estimate your monthly operations.
  • Auto-pause savings: If your workload has predictable idle periods, set auto-pause to a short delay (e.g., 5 minutes) to save compute costs. But remember, cold starts add latency.

For a quick estimate, use the provider’s pricing calculator, but remember to include I/O and storage replication costs if they aren’t bundled.

Common Problems and Misconceptions

Here are frequent issues users encounter:

  • Cold starts: When a database is paused, the first connection may take 10-30 seconds to resume. This is a problem for latency-sensitive applications. Solution: set a longer auto-pause delay (e.g., 1 hour) or keep a minimum compute level.
  • Scaling lag: During sudden spikes, the system may not scale fast enough, causing throttling or timeouts. Some providers have a “burst” feature, but it’s limited. Test your workload to see if scaling keeps up.
  • Cost surprises: Because I/O and compute are metered per second, a misbehaving query or a DDoS attack can rack up charges. Set budgets and alerts, and use query timeouts.
  • Misconception: “Serverless means no capacity limits”: There are always maximums (e.g., max ACUs, max vCores, max storage). You must set these to avoid hitting limits during peaks.
  • Misconception: “Serverless is always cheaper”: For a constant 24/7 workload, provisioned instances are usually cheaper. Serverless is best for variable or low-usage workloads.

Choosing Between Serverless and Provisioned

To decide, ask yourself:

  • Is my workload predictable? If yes, provisioned may be cheaper.
  • Do I have long idle periods? If yes, serverless saves money.
  • Can I tolerate cold starts? If no, keep a minimum compute or use provisioned.
  • Do I need fine-grained scaling? Serverless offers that.

Also consider hybrid options: some providers allow you to set a minimum compute to avoid cold starts, while still scaling up elastically. This is often the best of both worlds.

Safety and Best Practices

When using serverless SQL databases, follow these practices to avoid issues:

  • Set a minimum compute to avoid cold starts for critical applications.
  • Set a maximum compute to cap costs.
  • Enable automatic pause for dev/test environments.
  • Monitor I/O usage and set alerts.
  • Use connection pooling to reduce the number of new connections, which can trigger scaling events.
  • Test your application’s behavior during scaling events, especially if you use transactions that span multiple statements.

Frequently Asked Questions

What happens to my data when the serverless database is paused?

Your data remains intact in the storage layer. The compute is shut down, but the storage is still active and billed. When a new connection arrives, the database resumes and your data is available as before.

How do I avoid cold start latency?

Configure a minimum compute level (e.g., 1 ACU or 1 vCore) so the database never fully pauses. This increases cost but eliminates cold starts. Alternatively, set a longer auto-pause delay (e.g., 60 minutes) to reduce the frequency of pauses.

Is serverless SQL database good for production workloads?

Yes, for workloads with variable or low traffic. Many production applications use serverless databases successfully. However, for high-throughput, steady-state workloads, provisioned instances may be more cost-effective and predictable.

How is I/O billed in serverless databases?

I/O is billed separately from compute and storage, typically per million read/write requests. The exact price varies by provider and region. You can estimate your I/O costs by monitoring your current workload or using the provider’s calculator.

Can I convert a provisioned database to serverless?

Most providers allow you to switch between provisioned and serverless for the same database engine. For example, you can change an Azure SQL Database from provisioned to serverless tier, or convert an Aurora provisioned cluster to serverless v2. The process may involve a brief downtime, so plan accordingly.

Understanding how serverless SQL databases allocate compute and storage is key to using them effectively. By separating these two resources, they offer flexibility and cost savings, but only if you configure them to match your workload patterns.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →