Skip to main content
emnode
Cost

Right-size underutilised Azure Database for PostgreSQL servers

One capability for the managed database bill: find every Azure Database for PostgreSQL flexible server that has sat underutilised for weeks, and drop its compute tier or vCore count to the size the workload actually needs, so you stop paying for cores that never run.

14 min·10 sections·AZURE

Last reviewed

Right-sizing PostgreSQL flexible servers: the basics

What does an oversized Azure Database for PostgreSQL server actually look like?

An Azure Database for PostgreSQL flexible server is billed first and foremost on its compute, and compute is the vCore count and tier you picked when the server was created. The price is fixed by the size, not by how busy the database is. A server provisioned with eight vCores in the General Purpose tier costs the same whether it is running flat out or sitting at four per cent CPU all month. When a server is consistently idle, the gap between the size you are paying for and the size the workload needs is pure waste on the bill, and it recurs every single hour until someone changes the SKU.

Azure Advisor turns this into a cost recommendation. Advisor watches the server's utilisation telemetry and, when a server has been underutilised for an extended period, it raises a right-sizing recommendation. For the sibling MySQL engine the recommendation reads, verbatim: 'Our internal telemetry shows that the MySQL database server resources have been underutilized for an extended period of time over the last 7 days. Low resource utilization results in unwanted expenditure which can be fixed without significant performance impact. To reduce your costs and efficiently manage your resources, we recommend reducing the compute size (vCores) by half.' The same right-sizing engine Advisor applies across MariaDB, MySQL and PostgreSQL produces the equivalent recommendation for a PostgreSQL flexible server: halve the vCores, or move down a tier, and keep the same workload.

Most of this overprovisioning is history, not need. A server sized for a launch that never reached the traffic that was forecast. A production SKU copied into a dev or staging environment that only sees a developer twice a week. A General Purpose server doing the job a Burstable one would do for a fraction of the price. The work is to find every flexible server whose CPU and memory have stayed low for weeks, confirm the low utilisation is steady-state rather than a quiet window before a known peak, and scale it to the size the workload actually uses.

In this lesson you will learn how an Azure Database for PostgreSQL flexible server is priced, how Azure Advisor decides a server is underutilised and worth right-sizing, how to confirm the low utilisation is genuine before you scale, and how to drop a server's tier or vCores safely with the az CLI or Bicep. The aim is a repeatable loop that turns Advisor's right-sizing recommendations into recurring savings on the database bill.

Fun fact

The half that nobody noticed

Azure Advisor's right-sizing recommendation for the managed database engines does not hedge: its standard remedy is to reduce the compute size by half. That tells you something about how common steady-state idle databases are. The recommendation engine has seen enough servers running at a fraction of their provisioned compute, week after week, that halving is the default first move rather than a cautious nudge. The compute was paid for in full the whole time, and in many estates the recommendation sits dismissed or unread, so the bill keeps charging for the half that nobody is using.

Finding underutilised PostgreSQL servers across a subscription

Priya runs the platform team at a scale-up whose Azure bill has crept up as the estate grew. Azure Advisor's Cost tab shows several right-sizing recommendations against Azure Database for PostgreSQL flexible servers that were provisioned generously during a growth push that never fully materialised.

Rather than scale them blind, Priya pulls the right-sizing recommendations from Advisor and then checks each flagged server's actual CPU and memory over the past weeks, so a genuinely idle server can be told apart from one that only looks quiet between known peaks.

Start by listing the Advisor cost recommendations that target PostgreSQL flexible servers. These are the servers Advisor has judged underutilised over a sustained window.

$ az advisor recommendation list --category Cost \ --query "[?contains(impactedField, 'flexibleServers')].{server:impactedValue, problem:shortDescription.problem}" -o table
Server Problem
------------------ ----------------------------------------
orders-pg-staging Right-size underutilized database server
reporting-pg-prod Right-size underutilized database server
# Now confirm utilisation per server before scaling. Idle staging = risk-free cut.

Advisor only flags servers underutilised over a sustained window, but confirm CPU and memory yourself before scaling, so you do not catch a server in a trough before a known peak.

How Azure Advisor decides a flexible server is underutiliseddeep dive

Advisor's right-sizing recommendation rests on the server's utilisation metrics in Azure Monitor. For an Azure Database for PostgreSQL flexible server the key signals are 'cpu_percent' and 'memory_percent' in the 'Microsoft.DBforPostgreSQL/flexibleServers' namespace, each emitted at a one-minute interval. Advisor analyses these over a sustained look-back window, an extended period over roughly the last seven days for the equivalent managed-database recommendation, and when utilisation stays low throughout, it concludes the provisioned compute is larger than the workload needs and raises the recommendation, typically suggesting the vCores be reduced by half.

Compute is what you are paying to reduce. A flexible server's compute is a tier ('Burstable', 'GeneralPurpose' or 'MemoryOptimized') and an SKU within it (for example 'Standard_B1ms', 'Standard_D2s_v3' or 'Standard_D4s_v3'), and the compute charge is fixed by that choice regardless of how busy the database is. Right-sizing means moving to a smaller SKU in the same tier, or moving down a tier entirely, for instance from General Purpose to Burstable for a workload that does not need continuous full capacity. Storage is billed separately and is not what this recommendation is about.

Two mechanics shape how you act on the recommendation. First, scaling compute requires a server restart, so the change is applied during a brief window of unavailability rather than instantly and silently. Second, PostgreSQL flexible server does not support in-place vertical scaling from the Burstable tier up to the other tiers, so a server you move down to Burstable is a deliberate choice you should be confident about, because moving it back up is not a simple in-place operation. Neither mechanic blocks the saving; they just mean you schedule the restart and you are sure about a move to Burstable.

What is the impact of leaving servers oversized?

The direct impact is recurring waste. An oversized flexible server charges its full compute rate every hour it runs, whether or not the workload uses the cores, so the gap between the SKU you pay for and the SKU the workload needs is money leaving the account on a continuous basis. Advisor's standard remedy of halving the vCores hints at the scale of it: where the recommendation applies, roughly half the compute spend on that server has been buying capacity that sat idle.

The second-order impact is drift that compounds. One oversized server is a rounding error; an estate where provisioning-time guesses are never revisited is a structural overspend that grows with every new service. Each server that is sized once and forgotten adds a permanent line to the bill, and because managed-database spend looks stable and predictable, the waste hides in plain sight. Right-sizing as a routine keeps the bill tracking actual usage instead of accumulating the high-water mark of every past forecast.

On the upside, the saving is durable and free to capture. Unlike a discount that has to be purchased or a commitment that has to be negotiated, right-sizing an idle server costs nothing and the lower rate persists for the life of the workload. It also stacks: a server right-sized to the SKU it actually needs is then a smaller, cheaper base to apply a reserved-capacity commitment to, where Microsoft documents reserved pricing for PostgreSQL flexible server of up to 40 per cent for a one-year and up to 60 per cent for a three-year commitment. Right-size first, then reserve, so you are not committing to capacity you do not use.

How do you right-size a flexible server safely?

Work the capability as one loop rather than reacting to each recommendation in isolation. The order matters: confirm the low utilisation is genuine before you scale, so you do not undersize a server that is quiet only between known peaks.

1. Pull the right-sizing recommendations and the spend behind them

List Azure Advisor's cost recommendations that target PostgreSQL flexible servers and attach each server's current compute spend. Rank by the recurring saving available, the price gap between the current SKU and a halved one, so the largest, most idle servers are addressed first. Treat the recommendation list as the candidate set, not the final decision.

2. Confirm the low utilisation is steady-state

For each flagged server, check 'cpu_percent' and 'memory_percent' in Azure Monitor over a window long enough to span its normal cycles, a full month if the workload has a month-end batch. A server that is genuinely idle throughout is a risk-free cut. A server that is quiet most of the time but peaks predictably needs a sizing decision against that peak, not a reflex halving.

3. Scale to the right SKU, expecting a brief restart

Move the server to a smaller SKU in the same tier, or down a tier (for example General Purpose to Burstable) for a workload that does not need continuous capacity. Scaling compute restarts the server, so do it in a maintenance window. Remember that moving down to Burstable is not reversible by in-place scaling, so be sure about that move before you make it.

4. Make right-sizing routine, then layer reservations

Bake an Advisor cost-recommendation review into the regular cost cycle so right-sizing happens continuously rather than once. Where a right-sized server runs a steady, long-lived workload, apply a reserved-capacity commitment on top, sized to the new SKU, to stack a further documented saving of up to 40 per cent for one year or up to 60 per cent for three on the already-reduced footprint.

# 1. Confirm the server has genuinely sat idle: average CPU over the last 7 days.
az monitor metrics list \
  --resource "$SERVER_ID" \
  --metric cpu_percent \
  --interval PT1H \
  --aggregation Average \
  --start-time "$(date -u -d '7 days ago' '+%Y-%m-%dT%H:%M:%SZ')" \
  --query "value[0].timeseries[0].data[?average > \`20\`] | length(@)" -o tsv
# A low count of hours above 20% CPU confirms steady-state idle: safe to scale down.

# 2. Right-size: drop General Purpose 4 vCores to Burstable. --yes accepts the restart.
az postgres flexible-server update \
  --resource-group rg-data \
  --name reporting-pg-prod \
  --tier Burstable \
  --sku-name Standard_B1ms \
  --yes

Quick quiz

Question 1 of 5

Azure Advisor raises a right-sizing recommendation against a PostgreSQL flexible server. What is it telling you?

You can now treat right-sizing as one capability rather than a scatter of Advisor flags: pull the cost recommendations against your PostgreSQL flexible servers, rank them by the recurring saving behind each, confirm the low utilisation is genuine, scale the idle servers down with the az CLI or Bicep, and make the review a routine so the database bill keeps tracking actual usage. Right-size first, then layer reservations on the smaller footprint.

Back to the library