Question: How many nodes can a PostgreSQL cluster have?


A PostgreSQL cluster refers to a group of databases that share the same data directory on a single server. However, when discussing scaling and high availability in a broader sense, PostgreSQL can be part of a setup involving multiple servers—often referred to as nodes.

The number of nodes you can have in a PostgreSQL high-availability or replication cluster is not explicitly limited by PostgreSQL itself but is instead constrained by the architecture and the tools used for managing the cluster. Here are typical setups:

  1. Streaming Replication: PostgreSQL supports built-in streaming replication, where one primary server handles writes, and multiple standby servers handle reads. The actual limit on the number of nodes depends on network bandwidth, disk I/O, and the specific workload. Practical deployments often include a few standbys (2-5), but more can be added if the environment allows.

  2. Logical Replication: Introduced in PostgreSQL 10, logical replication allows changes to be sent to subscribers, which can be useful for scenarios like aggregating data from multiple databases. Each subscription connection will add overhead, so the practical limit depends on your system's resources.

  3. External Tools: Tools like Patroni, Pgpool-II, and others can manage larger clusters by handling failover and load balancing. The design of your architecture (including hardware and network considerations) generally sets the practical limit for node count.

  4. Cloud Services: Managed PostgreSQL services like Amazon RDS, Google Cloud SQL, and Azure Database for PostgreSQL can simplify scaling and high availability. They typically allow easy configuration of several read replicas.

In summary, while PostgreSQL doesn't impose a hard limit on the number of nodes in a cluster, effective management and resource availability are the practical constraints. Each additional node introduces more complexity and requires careful planning and monitoring to maintain performance and reliability.

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.