Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to figure out exactly how to configure nginx and tomcat to work together correctly.

Nginx has a worker connections setting and tomcat has max threads (assuming native apr connector for tomcat). Since nginx is connecting with HTTP/1.0 to backend, keepalive is not needed for tomcat.

I set keep-alive timeout to 30s in nginx. If 100 req/s is the target and each request finishes in 1s, there can be 100 requests * 30 seconds each = 3000 concurrent connections that can be opened to nginx and there will be 100 concurrent connections to tomcat.

So if I set worker connections to 6000 in nginx (worker process is 1, and nginx consumes 2 connection per request I think. One for client and one for backend) and max threads to 100 in tomcat (which is already 200 by default), this will work.

Is there any conceptual problem in this calculation? The exact numbers do not matter.


share|improve this question

There are two points you should consider in working out the above calculations:

  • There is a difference between a connection and a thread. This page breaks this down a bit, but each request is a thread. There will be many requests per connection.
  • RAM is another monitoring factor here. How much memory does each thread take up and how much do you have on your machine can be limiting factors.

Otherwise it looks pretty sound.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.