Question: How do you scale Azure PostgreSQL?


Scaling in the context of Azure Database for PostgreSQL refers to adjusting the resources available to your database server, such as compute (vCore), storage, and I/O throughput, to meet changing demands. Here's an overview of how you can scale Azure PostgreSQL:

Vertical Scaling

Vertical scaling involves increasing or decreasing the CPU, RAM, or I/O resources for your Azure PostgreSQL server instance without modifying your code or configurations. This is usually done to handle increases in load, such as more users, transactions, or data volume.

Example: Scaling Compute Resources

-- Note: There's no direct SQL command to scale Azure PostgreSQL. -- Scaling operations are performed through the Azure portal or Azure CLI. # Example Azure CLI command to scale up the compute resources: az postgres server update --resource-group myResourceGroup --name myServer --compute-units 100

Key Points:

  • You can perform vertical scaling operations from the Azure Portal, Azure CLI, or PowerShell.
  • The operation might cause a short downtime as the service transitions to the new configuration.

Horizontal Scaling

Horizontal scaling (read replicas) involves adding more instances to handle read-heavy workloads more efficiently. This allows you to distribute the read queries across several instances, thus improving the performance of read operations.

Example: Creating a Read Replica

# Example Azure CLI command to create a read replica: az postgres server replica create --name myReplicaServer --source-server myServer --resource-group myResourceGroup

Key Points:

  • Read replicas support read-only workloads. Writes must go to the primary server.
  • You can have up to five read replicas for each primary Azure PostgreSQL server.
  • Replication between the primary server and its replicas is asynchronous.


While Azure Database for PostgreSQL doesn't directly offer autoscaling based on workload, it allows for flexibility through manual or automated scripts that monitor metrics (like CPU utilization or connection count) and adjust resources accordingly.

General Approach for Autoscaling:

  1. Monitor your database's performance metrics using Azure Monitor.
  2. Set up alerts for when key metrics reach thresholds that indicate scaling is necessary.
  3. Use Azure Functions or Automation Runbooks to trigger scaling actions based on these alerts.


Scaling your Azure PostgreSQL database involves either increasing the size of your existing server (vertical scaling) or adding more servers to distribute the load (horizontal scaling). While Azure provides tools for both, understanding your application's specific needs is crucial for choosing the right strategy.

Was this content helpful?

White Paper

Free System Design on AWS E-Book

Download this early release of O'Reilly's latest cloud infrastructure e-book: System Design on AWS.

Free System Design on AWS E-Book
Start building today

Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement.