Master Tomcat Performance: Key Components and Tuning Tips for Max Throughput

This article explains Tomcat’s internal component architecture, walks through the request‑processing flow, and details three crucial configuration parameters—maxThreads, maxConnections, and acceptCount—offering practical formulas and tuning guidelines to improve throughput without adding hardware.

Su San Talks Tech
Su San Talks Tech
Su San Talks Tech
Master Tomcat Performance: Key Components and Tuning Tips for Max Throughput

For many SpringBoot applications the default servlet container is Tomcat. When traffic grows, simply scaling out may not be enough; performance tuning of Tomcat can improve throughput without extra cost.

Component Architecture

Tomcat abstracts its functionality into several components:

Server : the outermost abstraction representing the Tomcat instance; it can contain multiple Service components.

Service : groups a set of Connectors and a single Container; multiple Connectors allow handling different protocols.

Connector : manages client connections and supports protocols such as BIO, NIO, and AIO, shielding the Container from protocol complexity.

Container : processes business logic; the request is forwarded to its Engine component.

The Container further contains:

Engine : the servlet engine that can host multiple virtual hosts (Host).

Host : represents a virtual host and manages deployed web applications.

Context : the specific web application, managing its servlet instances.

Wrapper : the lowest‑level container that wraps an individual servlet.

Core Parameters

Understanding Tomcat’s request flow helps identify the three most critical parameters for tuning:

acceptCount : maximum number of connections the operating system will accept when the Connector’s queue is full and all Container threads are busy.

maxConnections : maximum number of connections the Connector can queue when the thread pool is saturated.

maxThreads : maximum number of request‑processing threads in the Container’s thread pool.

maxThreads

Default is 200 in Tomcat 7/8. The recommended value can be estimated with the formula: ((IO time + CPU time) / CPU time) * CPU cores This aims to keep the CPU busy while tasks wait for I/O. The calculated value is usually much larger than the number of CPU cores because I/O time dominates. However, setting the value too high causes excessive context switching, so the formula provides a baseline that should be validated with load testing.

maxConnections

Typically set to the same value as maxThreads . This ensures the Connector’s queue does not grow indefinitely, which could lead to memory pressure and OOM. Lowering it slightly can reduce response time, but setting it too low may throttle throughput.

acceptCount

Defines how many additional connections the OS will accept when both the thread pool and Connector queue are full; default is 100. It should not exceed maxConnections , because excess accepted connections would simply wait longer, increasing latency.

Historically, acceptCount and maxConnections were identical in BIO mode; with NIO/AIO they diverge, allowing the OS to accept more connections while the Connector processes them efficiently.

Other Useful Parameters

connectionTimeout : time to wait for a client to complete the connection handshake before timing out.

minSpareThreads : minimum number of idle threads to keep alive, helping handle sudden traffic spikes.

Summary

The article covered Tomcat’s core components, the request‑processing flow, and three key tuning parameters—maxThreads, maxConnections, and acceptCount—along with practical advice on how to calculate or choose appropriate values and additional settings such as connectionTimeout and minSpareThreads.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

BackendJavaConnectorperformance tuningthread poolTomcatServer Configuration
Su San Talks Tech
Written by

Su San Talks Tech

Su San, former staff at several leading tech companies, is a top creator on Juejin and a premium creator on CSDN, and runs the free coding practice site www.susan.net.cn.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.