10

I have a very low traffic site running on nginx, with 4 workers, 1024 connections each.

Every several hours I start seeing in the error log "1024 worker_connections are not enough", and my site slows down / becomes flakey. A nginx restart solves the problem entirely for the next several hours.

Clearly something odd is happening, there is no way I'm serving 4k concurrent users of my application.

Other than looking at the access log (which looks normal), is there a way to observe with greater details what nginx is doing?

Is there some notorious configuration combination that might result in old connections being held open and not closed?

Thanks.

edit this looks not right

# lsof |grep nginx |grep CLOSE_WAIT |wc -l
1271
John Bachir
  • 2,344
  • 7
  • 29
  • 37
  • are you using proxypass? – Dan R Dec 04 '10 at 00:56
  • Nope, I'm not using any kind of proxy setup. It's a rails site on passenger. – John Bachir Dec 04 '10 at 02:29
  • 1
    Maybe try http://nginx.org/en/docs/debugging_log.html enabling that to see which requests this happens with. I'm not familiar with passenger / rails. If this is on the port connecting to web clients, the client has closed the connection but nginx hasn't closed on its side. – Dan R Dec 04 '10 at 03:29

1 Answers1

8

Without proxy pass / reverse proxy

max_clients = worker_processes * worker_connections

With reverse proxy

max_clients = (worker_processes * worker_connections ) / (X * 2)

2 is because you open a connection to what you are proxying

X is however many concurrent connections these clients make to you

To see which connections are hanging around you could run lsof -i :PORT. It will show all connections open to nginx, and their state.

Dan R
  • 2,275
  • 1
  • 19
  • 27