The Problem
You have several node processes running in some cluster, one per core, but your cluster has several VMs, so many processes are running. Each process is independent and you're loading balancing them so their average workloads are similar.
You're running postgres, and you want to take best advantage of connection pooling, as the cost of establishing connections is really high otherwise.
- You want to ensure you don't overload postgres with too many connections.
- You want to ensure the cluster is highly available even during low load times (i.e. you don't want a customer to incur the slowness of connection establishment if use of the service was previously quite idle).
Proposed Solutions
- Use a per-node pod connection pool: node-pg-pool or a sidecar PGBouncer setup (if you're using docker or k8s or something like that).
- Use a connection pooling service that all node processes in the cluster connect to.
Is it okay to keep several connections idling across the cluster all the time to ensure high availability? Are there any particulars one should keep in mind so that this solution scales effectively?