ha/citus
13-node Citus distributed PostgreSQL cluster, 1 coordinator + 5 worker groups with HA
The ha/citus template deploys a complete Citus distributed PostgreSQL cluster with 1 infra node, 1 coordinator group, and 5 worker groups (12 Citus nodes total), providing transparent horizontal scaling and data sharding.
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
This is a 13-node template. Modify the node 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), receives queries and routes to workers, 1 primary + 1 replica
- pg-citus2~6: Workers (group 1~5), store sharded data, each with 1 primary + 1 replica via Patroni
- VIP: Each group has L2 VIP managed by
vip-managerfor transparent failover
Explanation
The ha/citus template deploys production-grade Citus cluster for large-scale horizontal scaling scenarios.
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: Choose wisely (typically tenant_id or timestamp), critical for performance
- Cross-shard Limits: Foreign keys must include distribution column, some DDL restrictions
- Network:
pg_vip_interfacedefaults toauto; specify an interface explicitly for unusual network environments - Architecture: Citus extension does not support ARM64