Choosing the right PostgreSQL workloads on Azure

Michael John Peña
5 min readOct 16, 2023

--

Choosing the right PostgreSQL workloads on Azure
PostgreSQL workloads on Azure

PostgreSQL is a powerful (and well-loved), open-source object-relational database system that uses and extends the SQL language combined with many features that safely store and scale the most complicated data workloads. It’s a great choice for many developers and businesses due to its performance, scalability, and flexibility. Azure offers three options for hosting your PostgreSQL data:

Azure Cosmos DB for PostgreSQL

Azure Cosmos DB for PostgreSQL

Azure Cosmos DB for PostgreSQL, powered by the Citus open source extension, is a fully-managed database service that provides seamless scalability for your relational apps. It’s designed to handle the demands of modern, cloud-native applications that require flexible scaling and high performance.

Here’s what makes Azure Cosmos DB for PostgreSQL stand out:

Start Small, Scale Big: You can start building apps on a single node cluster, just like you would with traditional PostgreSQL. As your app’s scalability and performance requirements grow, you can easily scale to multiple nodes by transparently distributing your tables.

Cluster-Oriented Approach: Unlike traditional PostgreSQL workloads where you work with a single database, Azure Cosmos DB for PostgreSQL allows you to work with distributed tables from Day 1. This cluster-oriented approach enables high scalability and performance.

High Throughput: Azure Cosmos DB for PostgreSQL is used in various real-world applications spanning verticals such healthcare, IoT data, finance, logistics, and search. It’s ideal for SaaS apps, real-time operational analytics apps, and high throughput transactional apps.

Fully Managed Service: Azure Cosmos DB for PostgreSQL takes care of all the operational aspects of running a database. It offers automatic high availability, backups, built-in pgBouncer, read-replicas, easy monitoring, private endpoints, encryption and more.

Wit the use of Citus, Azure Cosmos DB for PostgreSQL supports the latest PostgreSQL major version within a week of release. This means your apps can always use the newest PostgreSQL features and extensions. The free tier of Azure Cosmos DB offers the first 1000 RU/s and 25 GB of storage in the account for free. This makes it a cost-effective choice for developers and businesses looking to scale their applications.

Distributed Table — Transaction Execution

Azure Database for PostgreSQL — Flexible Server

Azure Database for PostgreSQL

Azure Database for PostgreSQL — Flexible Server is a fully managed database service that provides a suite of impressive features:

  • Granular Control and Flexibility: More control over database management functions and configuration settings.
  • Migration and Modernization: Ideal for migrating and modernizing existing PostgreSQL or Oracle applications to Azure.
  • Increased Price-Performance: Offers support for burstable tier compute.
  • Improved Uptime: Provides a hot standby server for improved uptime.
  • Simplified Developer Experience: Offers a streamlined experience for developers.
  • High Availability: Supports high availability within a single availability zone and across multiple availability zones.

In addition to these, the Flexible Server architecture allows users to collocate the database engine with the client tier for lower latency. It also provides better cost optimization controls with the ability to stop/start your server and a burstable compute tier ideal for workloads that don’t need full compute capacity continuously. The service supports the community version of PostgreSQL 11, 12, 13, and 14.

The architecture separates compute and storage. The database engine runs on a container inside a Linux virtual machine, while data files reside on Azure storage. The storage maintains three locally redundant synchronous copies of the database files ensuring data durability. If zone redundant high availability is configured, the service provisions and maintains a warm standby server across the availability zone within the same Azure region. The data changes on the source server are synchronously replicated to the standby server to ensure zero data loss.

Multiple Availability Zone for PostgreSQL Flex Server

Although there is the Single Server option, it is already in sunset mode and it’s recommended to migrate or not choose that option.

Azure Virtual Machines for PostgreSQL

Azure Virtual Machines for PostgreSQL

Azure Virtual Machines for PostgreSQL is an Infrastructure as a Service (IaaS) offering that allows you to run PostgreSQL Server inside a fully managed virtual machine on the Azure cloud platform.

Here are some key features of this service:

  • Full Control: Offers control over the database engine, allowing you to manage your database, apply patches, and make backups.
  • Latest PostgreSQL Versions: Supports all recent versions and editions of PostgreSQL.
  • Database Administration Tasks: While this service provides control over the database engine, it also requires you to manage many database administration (DBA) tasks. These tasks include maintaining and patching database servers, database recovery, and high-availability design.
  • High Availability: Customers architect, implement, test, and maintain high availability. Capabilities might include clustering, replication etc.
  • Backup and Restore: Backup and restore operations are managed by the customer.
  • Monitoring Database Operations: Customers have the ability to set alerts on the database operation and act upon reaching thresholds.

This option is ideal for those who need full control over their PostgreSQL environment and are willing to manage the associated administrative tasks. However, it’s important to note that this control comes at the cost of responsibility to manage the VMs and many DBA tasks.

Traditional Virtual Machine Cluster architecture for SQL workloads

Comparison

PostgreSQL on Azure Workload Comparison

Azure offers a variety of options for hosting PostgreSQL workloads, each with its own unique set of features and benefits. Azure Cosmos DB for PostgreSQL is ideal for building new cloud-native and highly scalable relational apps, while Azure Database for PostgreSQL — Flexible Server is best suited for migrating and modernizing existing PostgreSQL or Oracle applications to Azure. On the other hand, Azure Virtual Machines for PostgreSQL offers full control over the database engine, making it a great choice for those who need full control over their PostgreSQL environment and are willing to manage the associated administrative tasks.

But wait, there’s actually a 4th option. Kind of. That is Azure Arc-enabled PostgreSQL. This service is still in preview, but basically it allows you to manage an on-premises (hybrid scenarios) instance of PostgreSQL but centrally managed using Arc.

Arc-enabled PostgreSQL

--

--

Michael John Peña

Data & AI Director @ Playtime Solutions with a passion for emerging data technologies. Talks about Microsoft Fabric, Synapse, Vector Databases, LLMs, and Spark.