Master Tomcat Performance: Essential JVM Startup Parameters Explained
This guide details essential Tomcat startup parameters for both Linux and Windows environments, explains the purpose of each JVM option, and provides practical steps to test and adjust memory settings, helping you optimize server performance and avoid common pitfalls.
Linux Tomcat startup parameters
export JAVA_OPTS="-server -Xms1400M -Xmx1400M -Xss512k -XX:+AggressiveOpts -XX:+UseBiasedLocking -XX:PermSize=128M -XX:MaxPermSize=256M -XX:+DisableExplicitGC -XX:MaxTenuringThreshold=31 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -Djava.awt.headless=true"Windows Tomcat startup parameters
set JAVA_OPTS=-server -Xms1400M -Xmx1400M -Xss512k -XX:+AggressiveOpts -XX:+UseBiasedLocking -XX:PermSize=128M -XX:MaxPermSize=256M -XX:+DisableExplicitGC -XX:MaxTenuringThreshold=31 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -Djava.awt.headless=trueThe above parameters are extensive; they are specific to my machines and may need adjustment based on your environment, especially the memory values.
Parameter explanations:
-server : Must be added for production Tomcat to run in server mode, providing higher concurrency and better garbage collection.
-Xms and -Xmx : Set initial and maximum heap size to the same value for optimal performance, preventing large GC pauses when memory usage spikes.
To determine the maximum usable heap, run java -version and verify the displayed JDK version; then test memory limits with commands like java -Xmx2048m -version, adjusting until the JVM starts successfully.
-Xmn : Sets young generation size (e.g., 512m); recommended to be about 3/8 of total heap.
-Xss : Thread stack size, typically not exceeding 1M to avoid out‑of‑memory errors.
-XX:+AggressiveOpts : Enables new JVM optimizations when available.
-XX:+UseBiasedLocking : Optimizes thread locking for high‑concurrency web servers.
-XX:PermSize / -XX:MaxPermSize : Configure non‑heap memory; important for large file exports to prevent memory‑overflow errors.
-XX:+DisableExplicitGC : Prevents explicit System.gc() calls that can cause performance spikes.
-XX:+UseParNewGC and -XX:+UseConcMarkSweepGC : Enable parallel young‑generation collection and concurrent old‑generation collection for faster GC.
-XX:MaxTenuringThreshold : Controls object promotion age; tuning can reduce promotion failures.
-XX:+CMSParallelRemarkEnabled and -XX:+UseCMSCompactAtFullCollection : Reduce CMS pause times and memory fragmentation.
-XX:LargePageSizeInBytes : Sets Java heap page size.
-XX:+UseFastAccessorMethods : Compiles getter/setter methods to native code.
-XX:+UseCMSInitiatingOccupancyOnly and -XX:CMSInitiatingOccupancyFraction=70 : Start CMS when old generation reaches a certain occupancy, avoiding promotion failures.
-Djava.awt.headless=true : Required for headless environments (e.g., Linux) when generating graphics with libraries like JFreeChart.
Applying these settings can improve system response time, speed up JVM garbage collection, maximize memory utilization, and minimize thread blocking.
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.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
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.
