Horizontal scaling
Horizontal scaling allows you to distribute your RayDB PostgreSQL workload across multiple nodes, improving performance and reliability by adding more instances rather than increasing resources on a single instance.
When to Scale Horizontally
Consider horizontal scaling if:
- Your read operations are increasing significantly.
- You need high availability with replication.
- Your application requires geo-distributed access with lower latency.
How to Scale Your Cluster
Read Replicas
- Log in to the RayDB Dashboard.
- Navigate to the Clusters section and select your primary cluster.
- Go to the Replication & Scaling tab.
- Click Add Read Replica and select a region if needed.
- Confirm the setup to deploy additional read replicas.
Sharding (Partitioning Data)
For applications with high write workloads, consider sharding:
- Implement application-level sharding by distributing data across multiple clusters.
- Use PostgreSQL’s built-in table partitioning for managing large datasets efficiently.
Load Balancing
- Use a connection pooler such as PgBouncer to distribute read queries efficiently.
- Implement application-level logic to direct read queries to replicas and writes to the primary cluster.
Impact on Availability
- Read replicas are deployed asynchronously and provide non-blocking scaling.
- Application logic may need to be adjusted to handle distributed reads.
- Writes remain limited to the primary instance in a traditional setup.
Best Practices
- Monitor Query Performance – Use built-in monitoring to identify performance bottlenecks.
- Distribute Read Workloads – Direct read-heavy operations to replicas.
- Plan for Failover – Configure automatic failover strategies for high availability.
For more on optimizing performance, see Performance Tuning.