MOFAKH.COM
← Back to profile
Azure Fundamentals

Serverless or provisioned: paying for use versus paying for capacity

Nov 25, 202614 min readWritten

The same database can be billed two ways: provisioned, a fixed size charged every hour, or serverless, charged every second for what it uses. Serverless sounds cheaper and often is, but its price per vCore is higher, and it can bill for memory you are not really using. This part works through the arithmetic, the break-even point, how to size from percentiles, and what you take on when you switch.

This is the seventh part of the Azure series and the second about money. Part 6 introduced the most important cost question, allocated or consumed?, as a rule of thumb. This part turns that rule into arithmetic, using the service where the choice matters most and costs most: a managed SQL database.

The example is Azure SQL Database, because it offers both models side by side and because databases are usually the largest compute line on a real application's bill. Everything here applies equally to other services that come in provisioned and serverless flavours. The Azure data services topic later goes deep into Azure SQL itself; this part only uses as much of it as the pricing needs.

All prices in this part are illustrative round numbers, chosen to keep the arithmetic readable. Real prices differ by region, tier, hardware and currency. The ratios between them are realistic, and the method is exactly what a real cost analysis does.

Just enough Azure SQL vocabulary

Azure SQL Database is SQL Server run by Microsoft as a PaaS service (Part 1): you get a database, not a server. A few terms are needed to read its pricing:

TermMeaning
Logical servera named container for databases, with its own address and login settings. Not a machine: it holds no compute itself.
vCore purchasing modelyou choose the number of vCores, and memory comes with them at a fixed ratio
Service tierthe architecture underneath: General Purpose (balanced, budget-friendly), Business Critical (lowest latency, several hot standby copies), Hyperscale (very large storage, fast scaling, separate compute and storage)
Compute modelprovisioned (a fixed size) or serverless (sized automatically between a minimum and maximum)
HA replicaa standby copy of the database's compute, ready to take over if the primary fails
Read scale-outsending read-only queries to a replica instead of the primary, so the replica does useful work
Named replicaan extra replica you create yourself, with its own size, for a separate workload such as reporting

Hyperscale is worth one more sentence, because it explains why it scales so smoothly. Its storage is separate from its compute: the data lives in a distributed storage layer, and the compute nodes only cache what they use. So changing the compute size does not mean copying the data, which is why a Hyperscale database can be resized in minutes regardless of how big it is.

Model 1: provisioned compute

With provisioned compute, you choose a size, say 8 vCores, and that capacity is reserved for you around the clock. The bill is simple:

Diagram
provisioned cost per hour = vCores provisioned × price per vCore-hour × number of copies

It does not matter whether the database is busy or idle: 8 vCores are billed every hour. With one HA replica (Part 6: every copy is billed), that is 16 vCores every hour.

What you get for that predictability:

  • A known bill. The same amount every hour, unless you change the size.
  • A fixed amount of memory. Memory comes with the vCores at a fixed ratio for the hardware, so 8 vCores might come with around 40 GB.
  • The lower price per vCore. Because Microsoft can plan for capacity you have committed to, a provisioned vCore-hour is much cheaper than a serverless one.

What you give up: the database does not grow on its own. If load rises above what 8 vCores can handle, queries slow down until someone (or some automation) makes it bigger.

Model 2: serverless compute

With serverless compute, you set a minimum and a maximum number of vCores, and the database scales itself between them second by second, following the load. The bill follows what is used, measured per second.

The exact rule for Azure SQL serverless is worth reading carefully, because the details are where the surprises live. For each second, Azure works out three numbers and bills the largest:

Diagram
billed vCores (each second) = the largest of:
    vCores of CPU actually used
    memory actually used ÷ 3 GB     (memory converted into "vCore equivalents")
    the configured minimum vCores

The memory term is the one people miss. Serverless counts memory as well as CPU, at 3 GB of memory per vCore. A database using only 2 vCores of CPU but holding 30 GB of memory is billed for 10 vCores that second, because 30 ÷ 3 = 10 is the largest of the three numbers.

And each copy is billed this way separately: a serverless database with an HA replica pays for the primary's billed vCores and the replica's.

The advantages are real:

  • It follows the load automatically. A sudden burst gets more vCores within seconds, up to the maximum, with nobody watching.
  • Idle can be cheap. In the General Purpose tier, a serverless database can auto-pause after a period with no activity, after which only its storage is billed. (In Hyperscale, auto-pause is a newer preview feature.)
  • No sizing decision. You choose a range, not a size.

But the price per vCore-hour is higher than provisioned, typically around double. That single fact decides most of what follows.

Why memory can dominate the serverless bill

Databases love memory. SQL Server keeps recently used data pages in memory (the buffer pool) so that the next query reading them does not have to go to storage. A busy database gradually fills that cache, because cached data makes queries fast, and it does not give memory back eagerly.

That is excellent for performance and bad for a serverless bill. Picture PhotoDrop's database a few months after launch:

MeasurementValue
CPU actually used, on average1.5 vCores
Memory in use (mostly cache)18 GB
Configured minimum1 vCore
Billed vCores per copythe largest of 1.5, 18 ÷ 3 = 6, and 1 → 6
Copies (primary + HA replica)2
Billed vCores around the clock12

The database is doing about 1.5 vCores of real work per copy, and being billed for 6. The "pay for what you use" model is faithfully billing for what it uses; it is just that what it uses is mostly memory holding cached data, not processor time.

At an illustrative serverless price of USD 0.50 per vCore-hour:

Diagram
12 billed vCores × 0.50 × 730 hours  ≈  USD 4,380 per month   (≈ USD 52,600 per year)

This is the most important lesson of the part: serverless bills whatever its formula measures, and for a busy, cache-heavy database running all day, that can be far more than the CPU work suggests.

The break-even point

When is each model cheaper? Compare the same database over an hour, with illustrative prices where serverless costs twice as much per vCore:

Price per vCore-hourBilled vCores
ProvisionedUSD 0.25the size you chose, every hour
ServerlessUSD 0.50whatever the formula measures, each second

Serverless is cheaper only when its average billed vCores are below half the provisioned size you would otherwise need. With these prices:

Diagram
serverless is cheaper when:  average billed vCores × 0.50  <  provisioned size × 0.25
                       i.e.  average billed vCores  <  provisioned size ÷ 2

That gives a clean rule of thumb:

WorkloadBetter fitWhy
Idle most of the day, with occasional use (dev, test, a small internal tool)serverlessaverages well under half a provisioned size; can even auto-pause
Unpredictable bursts with long quiet periodsserverlesspays for bursts only when they happen
Busy around the clock, fairly steadyprovisionedthe average is high, so the lower per-vCore price wins
Large memory footprint relative to CPUprovisionedserverless bills the memory; provisioned memory is included in the size

PhotoDrop's development database is clearly serverless territory: it averages well under 1 vCore and sleeps at night. Its production database, billed for 12 vCores all day, is the opposite.

Sizing a provisioned database: percentiles, not averages

Moving to provisioned means choosing a size, and the obvious choice, the average CPU, is the wrong one. A database averaging 1.5 vCores of CPU may need more than twice that in its busiest hours; sized at the average, it would be slow exactly when it matters.

The right tool is percentiles. Take the CPU usage for every hour over a representative period, sort the hours from quietest to busiest, and read off:

PercentileMeaningPhotoDrop example
p50 (median)half the hours were at or below this1.5 vCores
p9090% of hours were at or below this2.5 vCores
p9999% of hours were at or below this; only the busiest 1% were higher3.5 vCores
maxthe single busiest moment5 vCores, for a few minutes

Then size for something like the p99, plus some headroom, and decide separately how to handle the rare moments above it. Sizing for the absolute maximum pays all year for a few minutes; sizing for the average guarantees regular slowdowns.

Memory needs a check too. On provisioned compute, memory comes with the vCores, so confirm the size you pick includes enough memory for the database's working set. Remember that much of a database's memory use is opportunistic cache, which simply fills whatever memory it is given; what matters is whether the data queried regularly fits. If 4 vCores come with about 20 GB and the regularly used data fits comfortably, 4 vCores is a reasonable size for PhotoDrop: p99 CPU of 3.5 plus a little headroom.

The provisioned cost, with an HA replica, at the illustrative USD 0.25:

Diagram
4 vCores × 2 copies × 0.25 × 730 hours  ≈  USD 1,460 per month   (≈ USD 17,500 per year)

Compared with about USD 52,600 a year on serverless, that is a saving of about two thirds, for the same database, the same data, the same HA replica, and comfortably enough capacity for the busy hours. The saving comes entirely from changing how it is billed. Part 8 then shows how a commitment takes a further large slice off the provisioned price; serverless cannot take that discount at all.

Where the numbers come from

None of this works without real measurements, and Azure collects them for you. Azure Monitor records metrics for every database every minute: CPU percentage, memory percentage, how busy its worker threads are, failed connections, and for serverless databases the vCores actually billed. The full list is in the documentation for each service, and the same metrics drive alerts and dashboards.

A CPU percentage converts to vCores by multiplying by the size: 25% of a 16-vCore maximum is 4 vCores. Pair these metrics with the cost data from Cost Management (Part 6) over the same period, and the question "why does this cost so much?" usually answers itself: here is what was billed, here is what was used, here is the gap.

What you take on when you leave serverless

Moving to provisioned is not free of cost in other ways. You are handing back a job that serverless was doing for you, and the job has to land somewhere.

You own scaling

On serverless, a burst gets more vCores automatically. On provisioned, a burst above the size simply slows down until the size changes. So someone, or something, has to watch and react. The usual toolkit:

  • Alerts on CPU, memory and worker usage, so that load which stays high, rather than a momentary blip, gets noticed.
  • Scheduled scaling, when the busy periods are predictable. If a heavy job runs at a known time, scale up before it and back down after.
  • Alert-triggered scaling: an alert starts an automation script (a runbook) that scales up and notifies someone.
  • Read offloading: send read-only queries to a replica (read scale-out), so the primary has more room.

Scaling a provisioned database is a control-plane operation (Part 4), so it can be done from anything that talks to Resource Manager:

bash
# Change the size of a provisioned database to 6 vCores
az sql db update --resource-group rg-photodrop-prod --server sql-photodrop-prod \
  --name photodrop --capacity 6

Scale operations interrupt connections

Changing the size is not invisible to the application. Even on Hyperscale, where no data has to move, the switch to the new size ends with a brief failover, and open database connections are dropped at that moment. Microsoft's general guidance for Azure SQL is the same for every such reconfiguration: they cause short-lived transient errors, and applications must be written to retry.

That turns a pricing decision into a code review. Before relying on regular scaling, a team needs to know:

  • Does every database call retry transient failures? Most data-access libraries can do this automatically, but only if it is turned on, and any code that talks to the database without going through that library is not covered.
  • Is every write safe to retry? If a command succeeded but the reply was lost when the connection dropped, a retry runs it again. A command that inserts rows or adds to a total will then do it twice, unless it was written to be idempotent: safe to run more than once with the same result.
  • What happens to long-running work? A 10-minute report query that is cut off at minute 9 starts again from the beginning. Long jobs need to be restartable, or scaling has to avoid the times they run.

These are not exotic concerns; they are the normal rules for any code that talks to anything over a network. Moving to provisioned compute just makes them non-optional.

The change is reversible, until you commit

Changing the compute model is just another update to the same database, so it can be changed back the same way. That reversibility is worth protecting: measure before and after, make sure the application copes with the switch, and keep the command to go back at hand. The one step that is not easily reversible is the commitment discount in Part 8, which is why it belongs at the end, once the new size has proven itself.

The one idea to hold onto

Provisioned compute bills a fixed size every hour at a low price per vCore; serverless bills each second for the largest of CPU used, memory used ÷ 3 GB, or the minimum, at roughly double the price per vCore, for every copy. Serverless wins for idle or bursty workloads (averaging under about half a provisioned size), and provisioned wins for busy, steady ones, especially cache-heavy databases whose serverless bill is driven by memory. Size provisioned capacity from percentiles, not averages, and remember what you take on: alerts, scaling, and code that survives dropped connections and safe retries.

Further reading

What comes next

Moving PhotoDrop's database from serverless to provisioned cut its compute cost by about two thirds. Part 8 covers the next lever, which only provisioned capacity can use: committing to it. Reservations, savings plans and Azure Hybrid Benefit, how each discount is actually applied hour by hour, and the rules for changing your mind.