Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

Thanks.

share|improve this question
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

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.