Connection management of sync gateway


#1

Hi,
I have a nginx which routes my traffic to sync-gateway. To check the number of connections at nginx, I use netstat -an | grep :443 | wc -l which gives the output close to 15000. Then, to check how many connections sync gateway is handling, lsof reveals that 1200 connections are in CLOSE_WAIT state, 300 in ESTABLISHED and 2500 in can’t identify protocol.

As a result, while checking nginx error logs, I am getting a lot of upstream timed out while reading response header logs. Any cue on where I may be going wrong or these are expected numbers?


#2

It’s hard to tell exactly what’s going on from the information provided, but a few questions:

  1. Have you already reviewed the documentation here?
    http://developer.couchbase.com/documentation/mobile/current/develop/guides/sync-gateway/nginx/configuring-nginx-for-sync-gateway/index.html
    In particular I’m wondering whether the proxy_read_timeout setting would help avoid the “upstream timed out” errors.
  2. What version of Sync Gateway are you running? There are some enhancements in SG 1.2 related to closing half-closed connections. In this case you look like you’ve might have the opposite scenario - connections are closed on SG but open on nginx - but the underlying cause might still be addressed by the improved connection termination on the SG side.