Boost Tomcat Performance: Essential Configurations for Faster Servers
This guide explains the most important Tomcat configuration parameters—including concurrency, thread pool, JVM settings, and key Connector options—so you can optimize the web container for higher throughput and lower latency without getting lost in hundreds of obscure options.
Tomcat this old cat has reached version 10.0.2.
Tomcat has many configuration parameters, but focusing on the key ones can make it run faster.
Changing the server port is done in the server.xml file’s Connector section.
1. Three parameters for concurrency
Tomcat supports NIO; adjust thread and connection settings for best performance. maxThreads – maximum request processing threads, default 200, often set to around 1000 for high concurrency. maxConnections – maximum simultaneous connections; default 10000 for NIO, usually left unchanged. acceptCount – max queue size when threads are busy, often set equal to maxThreads.
Relationship: system can maintain connections = maxConnections + acceptCount (maxConnections are dispatchable, acceptCount are queued). System can process requests = maxThreads.
Deprecated parameters maxProcessors and minProcessors were removed after Tomcat 5.
Reference for Tomcat 8 configuration:
https://tomcat.apache.org/tomcat-8.0-doc/config/http.html2. Thread configuration
In Connector, thread pool settings include: namePrefix – thread name prefix. maxThreads – maximum threads in pool. minSpareThreads – always active threads. maxIdleTime – idle time before thread termination. threadPriority – thread priority, default 5.
Reference:
https://tomcat.apache.org/tomcat-8.0-doc/config/executor.html3. JVM configuration
Tomcat runs on Java, so JVM settings affect performance.
3.1 Memory region sizes
-XX:+UseG1GC– select G1 garbage collector. -Xmx – maximum heap size, typically two‑thirds of OS memory. -Xms – initial heap size, usually same as Xmx. -Xmn – young generation size; under G1 it is auto‑adjusted. -XX:MaxMetaspaceSize – metaspace limit, e.g., 256M. -XX:MaxDirectMemorySize – max direct memory. -XX:ReservedCodeCacheSize – JIT code cache size. -Xss – thread stack size, default 1M.
3.2 Memory tuning
-XX:+AlwaysPreTouch– pre‑touch memory at startup. -XX:SurvivorRatio – ratio of Eden to survivor space, default 8. -XX:MaxTenuringThreshold – object promotion age threshold. PretenureSizeThreshold – allocate large objects directly in old generation.
3.3 Garbage collector tuning (G1)
-XX:MaxGCPauseMillis– target GC pause time. -XX:G1HeapRegionSize – size of G1 heap regions. -XX:InitiatingHeapOccupancyPercent – heap occupancy threshold to start concurrent marking. -XX:ConcGCThreads – number of GC threads, usually left default.
4. Other important Connector settings
enableLookups– whether to perform DNS lookup for remote host. URIEncoding – character encoding for URLs, default ISO‑8859‑1. connectionTimeout – connection timeout in milliseconds. redirectPort – port for SSL redirection.
5. Summary
Tomcat is a widely used web container with hundreds of configuration options; focusing on the most important parameters—concurrency, thread pool, JVM, and key Connector settings—yields significant performance improvements without needing to master every option.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
macrozheng
Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
