ha/citus
13-node Citus distributed PostgreSQL cluster, 1 coordinator + 5 worker groups with HA
The ha/citus template deploys a Citus distributed PostgreSQL cluster.
It has 1 infrastructure node, 1 coordinator group, and 5 worker groups.
The coordinator and worker groups contain 12 Citus nodes in total.
The cluster distributes data into shards and supports horizontal scaling.
Overview
- Config Name:
ha/citus - Node Count: 13 nodes (1 infra + 1 coordinator×2 + 5 workers×2)
- Description: Citus distributed PostgreSQL HA cluster
- OS Distro:
el8,el9,el10,d12,d13,u22,u24,u26 - OS Arch:
x86_64 - Related:
meta,ha/trio
Usage:
Note: 13-node template, modify IP addresses after generation
Content
Source: pigsty/conf/ha/citus.yml
Topology
| Cluster | Nodes | IP Addresses | VIP | Role |
|---|---|---|---|---|
| pg-meta | 1 | 10.10.10.10 | - | Infra + CMDB |
| pg-citus1 | 2 | 10.10.10.21, 22 | 10.10.10.29 | Coordinator (group 0) |
| pg-citus2 | 2 | 10.10.10.31, 32 | 10.10.10.39 | Worker (group 1) |
| pg-citus3 | 2 | 10.10.10.41, 42 | 10.10.10.49 | Worker (group 2) |
| pg-citus4 | 2 | 10.10.10.51, 52 | 10.10.10.59 | Worker (group 3) |
| pg-citus5 | 2 | 10.10.10.61, 62 | 10.10.10.69 | Worker (group 4) |
| pg-citus6 | 2 | 10.10.10.71, 72 | 10.10.10.79 | Worker (group 5) |
Architecture:
- pg-meta: Infra node running Grafana, VictoriaMetrics, etcd, plus a standalone CMDB
- pg-citus1: Coordinator group 0 with 1 primary and 1 replica. It receives queries and routes them to workers.
- pg-citus2~6: Worker groups 1~5 store sharded data. Patroni manages 1 primary and 1 replica in each group.
- VIP: Each group has L2 VIP managed by
vip-managerfor transparent failover
Explanation
Use ha/citus to deploy a production Citus cluster that can scale across multiple worker groups.
Key Features:
- Horizontal Scaling: 5 worker groups for linear storage/compute scaling
- High Availability: Each group with 1 primary + 1 replica, auto-failover
- L2 VIP: Virtual IP per group, transparent failover to clients
- SSL Encryption: Inter-node communication uses SSL certificates
- Transparent Sharding: Data auto-distributed across workers
Pre-installed Extensions:
Security:
pg_dbsu_passwordenabled for Citus inter-node communication- HBA rules require SSL authentication
- Inter-node uses certificate verification:
sslmode=verify-full
Deployment
Verify after deployment:
Examples
Create Distributed Table:
Create Reference Table (replicated to all nodes):
Use Cases
- Multi-tenant SaaS: Shard by tenant_id for data isolation and parallel queries
- Real-time Analytics: Large-scale event data aggregation
- Timeseries Data: Combine with TimescaleDB for massive timeseries
- Horizontal Scaling: When single-table data exceeds single-node capacity
Notes
- PostgreSQL Version: Citus supports PG 14~18, this template defaults to PG18
- Distribution Column: Select this column for the workload, typically tenant_id or timestamp. This choice is critical for performance.
- Cross-shard Limits: Foreign keys must include the distribution column. Some DDL operations also have restrictions.
- Network:
pg_vip_interfacedefaults toauto. For unusual network environments, explicitly select an interface. - Architecture: Citus extension does not support ARM64
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)