In a configuration of N couchbase server nodes does it make sense for also have N sync gateways (one on each server node) and have a load balancer distribute requests to them? And by that I don’t mean send all requests to one sync gateway till it’s unreachable and then switch to another one, but, rather route to all of them equally.
To ensure high availability of Sync Gateway in production it’s a good idea to deploy multiple Sync Gateway instances and use a reverse proxy/load balancer to distribute requests across the instances.
There is some documentation on configuring nginx as a reverse proxy/load balancer for use with Sync Gateway.
@nkonstas Andy is correct about the benefits of using a load balancer to distribute load across a cluster of SG nodes.
A few additional thoughts on your suggestion of deploying one Sync Gateway per Couchbase Server node:
There usually isn’t a 1-to-1 correlation between the required number of Couchbase Server nodes, and Sync Gateway nodes.
It’s generally not recommended to deploy Sync Gateway and Couchbase Server to the same nodes in a production environment. There are exceptions, but generally they are deployed to different nodes, for a few reasons:
Sync Gateway needs to be internet-facing, and Couchbase Server generally shouldn’t be.
Having Sync Gateway and Couchbase Server compete for resources (memory, CPU) under load can amplify the impact of the load.
In our setup the Couchbase Servers and the SGs are on a private LAN (non-internet facing). All internet traffic goes through our reverse proxy / load balancer.
I totally understand the additional resource load - I’ll keep an eye on that and if performance degrades I’ll move the SGs on separate servers.