Sync Gateway Performance Issues

Hi, we are having a lot of performance issues with Sync Gateway and I’m not sure if it’s a problem with how we’ve configured our server or not. We’re using nginx as a reverse proxy but we don’t use any longopoll _changes requests, or websockets from iOS devices, so we don’t have any custom sync gateway configs in nginx. We have maybe a few dozen concurrent users, but are running sync gateway on the same box as couchbase itself. We’re using an Azure A3 server ( 4 cores at 2.0 GHz each, 7 GB memory). top shows we’re using about 1/4 of our available CPU and reach about 50% of RAM during peak load, with sync gateway using about 20% of our system’s total RAM. Not sure if it’s normal for sync gateway to use this much memory, since the docs say it’s actually supposed to be very light on memory.

The problem is that I can see it running and using memory when I use ‘top’ in the terminal, but if we actually query it (even a simple GET) I just get a 504 Gateway Timeout from nginx. I can see that it’s running, but it keeps not responding for 2 - 10 minutes at a time at various times during the day. A few days ago this happened and I got an error saying there weren’t any free TCP connections, but this time it just times out and we only have about 3000 TCP connections going.

I’m pretty new to server admin stuff so it could be some rookie mistake I made by failing to set some config property correctly, but I wanted to check here first to see if there is just some sync gateway setup I missed. Our sync-gateway-config file (minus sync function) is here:
“log”: [“CRUD”, “REST+”, “Shadow”, “Access”],
“facebook”: {
“register”: true
“CORS”: {
“Headers”: [“DNT”,“X-Mx-ReqToken”,“Keep-Alive”,“User-Agent”,“X-Requested-With”,“If-Modified-Since”,“Cache-Control”,“Content-Type”],
“MaxAge”: 1728000
“databases”: {
“todos”: {
“server”: “”,
“users”: {
“GUEST”: {
“disabled”: false

Thank you to anyone that can help shed some light on why this might be happening.

UPDATE: Turns out our apps were using longpoll, and by setting the keepalive and proxy timeouts to 360s it solved the problem. I now have about 4000 established sync gateway connections at any one time, because the apps poll continuously. I’m not sure if this is the default way to use CB and sync gateway since I’m not on the app team but if so then concurrent users will always be about equal to total users, since the app polls even when minimized.

1 Like