Azure SQL Serverless Auto Scale

I recently wrote about Azure SQL Database’s new serverless tier. I explored how to get started with serverless by covering the basics of how vCores are allocated and how much memory and storage is allowed based on vCores. What I didn’t dive deep into is how the auto scaling and billing works, so I’ll do that now.

The cost for a serverless database is the summation of compute cost and storage cost. Storage cost is determined just like it is for the provisioned compute tier, however compute usage is based on your settings and usage. For example, if your compute usage is between the min and max limits you’ve configured, compute is based on the vCore and memory used. If your usage is below the min limit you’ve configured, cost is based on the min vCores and min memory you’ve selected. (consider this your base cost). If you’ve enabled autopause, then compute is zero and only storage costs are incurred while the database is paused. This is what makes the serverless tier very appealing for workloads with prolonged inactive periods, systems with low compute usage, or enterprise workloads during business hours.

I configured a serverless database with a min .75 vCore and max of 6 vCore in the East US region. My vCore-second compute cost was $.000145. To avoid duplicating compute cost formulas that may get updated, I’ll refer you to the official document. The key takeaway is to know that both memory and CPU usage has a formula to calculate vCore seconds for billing.

For this exercise I created a few tables and inserted millions of rows. I then opened a few SSMS windows and did large selects to generate workload. I wanted to see how serverless would handle small request for data nd then much larger request.

Fortunately you can see App CPU billed in the Azure Portal. From the main dashboard, I see the aggregate in a 5 minute interval. On the left is my compute utilization with App CPU billed on the right.

If I click on the App CPU billed metric, I can drill down to per minute with the default 1 hour view. Using the image below we can see that I’ve used 10.88k of vCore seconds. With a cost of $.000145 per vCore second, I just used approx $1.58 USD for the previous hour of compute.

What impresses me so much about the serverless tier is how this can save organizations a tremendous amount of money. As you can see from the graphs, when my workload increased so did my spend, however when the workload decreased, my spend did as well.

Check out my video walk through where I demonstrate auto scaling and how to view App CPU billed.

3 thoughts on “Azure SQL Serverless Auto Scale

  1. At Helpwiz, we’ve been using Azure Functions serverless, and one of the things I’ve noticed is that the scaling up in response to demand is quite slow (on the order of minutes). How does this compare? Do you have any insight on how quickly it would scale to max from zero in response to a large demand impulse?

    1. In my testing, it was near real-time. Only within the min-max cores configured. The more I pushed, the more vCore and memory it consumed. I am not sure how Azure Functions allocates the resources for auto scaling.

      1. I have Azure SQL Databases that are running at low overall utilization, but once in a while an expensive query runs that uses 100% CPU for maybe 20 or 30 seconds. Two questions: 1) Would serverless auto-scale up fast enough to help? 2) What would the impact on the execution plan be for that query in terms of parallelism? Would it take advantage of the additional vCores even though when its execution started only the minimum might have been available?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Other articles

Imagine feeling confident enough to handle whatever your database throws at you.

With training and consulting from SQLskills, you’ll be able to solve big problems, elevate your team’s capacity, and take control of your data career.