Build scalable apps in Azure Cosmos DB for PostgreSQL

Important

Azure Cosmos DB for PostgreSQL is on a retirement path and no longer recommended for new projects. Instead, use one of these two services:

For existing Azure Cosmos DB for PostgreSQL deployments only, building scalable apps involves three steps. New projects must use one of the alternative services listed earlier and shouldn't follow the steps in this article.

  1. Classify your application workload. Common workloads where Azure Cosmos DB for PostgreSQL shines include:
    • Multitenant SaaS → tenant-isolated schemas or shard keys
    • Microservices → service-aligned distributed tables
    • Real-time operational analytics → co-located distributed data
    • High-throughput OLTP → row-based sharding with a high-cardinality key
  2. Based on the workload, use schema-based sharding or identify the optimal shard key for the distributed tables (for example, shard by tenant_id for a multitenant SaaS app so that all rows for a tenant are co-located; expected result: queries scoped to a tenant are routed to a single shard). Classify your tables as reference, distributed, or local.
  3. When using row-based sharding, update the database schema and application queries to optimize performance across nodes.

Success check: After completing these steps, tenant- or shard-key–scoped queries consistently target a single worker node and show stable low latency under load.

Next steps

Before you build a new app, review the architecture of Azure Cosmos DB for PostgreSQL.