[Tomcat] Mechanism of parallel processing and tuning method

What is Tomcat ?

Tomcat is  the software called a web container. It runs servlets, which are a type of Java program. It is the de facto standard OSS software that is installed in conjunction with Apache, so be sure to understand the basics. There are other products such as JBoss and products provided IBM or other companies. But I recommend that you keep tomcat in check first, since many of the ideas are similar to other products.

Mechanism of parallel processing provided by Tomcat

When Tomcat receives a request, it is stored in a queue. The queued requests are passed to the worker threads by the accept thread, and one worker thread communicates with the client one to one.

1. When a client sends a request, the Web Server (Apache) accepts the request first.
2. Apache connectors such as mod_jk make requests to tomcat
3. Accept thread takes the request from the queue and stores it in the Acceptor queue
4. The worker thread in the Thread Pool is associated with the request
5. Worker thread communicates with client one to one

Tuning Parameter for Tomcat

Tomcat requires a worker thread for each incoming request. If tomcat receives more requests that cannot be handled by the currently available worker threads, additional worker threads are created up to the maximum number set by maxThreads. If more concurrent requests are received, Tomcat will accept new connections until the current number of connections reaches maxConnections. Requests that exceed the limit are placed in the Acceptor queue until a worker thread becomes available. When the number of requests reaches maxConnections, the OS queues the overflow requests at the OS layer. The size of the connection queue provided by the OS can be controlled by acceptCount. Once the OS layer queue is full, further connection requests will be rejected or timed out.

Let me summarize the contents of the above parameters. I recommend tuning to an appropriate value based on the performance test results.

Reference

If you want to know more detail, please refer to below link.

Tuning Apache Tomcat for handling multiple requests
https://medium.com/@mail2dinesh.vellore/tuning-apache-tomcat-for-handling-multiple-concurrent-requests-99eee0d76dc0

Finally

Thank you for reading until the end. I also write other tuning-related content, so we would be happy if you could take a look.

コメント