Deploying a Java application on a server with default JVM settings is like buying a sports car and only ever driving in second gear. Proper configuration can be the difference between a 100ms and a 5-second response time.
Heap size¶
Basic rule: set -Xms and -Xmx to the same value. Dynamic heap size changes cause full GC pauses. On servers with 16 GB of RAM we typically allocate 8–10 GB for the JVM heap. PermGen: 256–512 MB for enterprise applications.
Garbage Collection — CMS¶
For web applications we use the Concurrent Mark Sweep collector. Parallel GC has better throughput, but its stop-the-world pauses can last seconds. CMSInitiatingOccupancyFraction=70 — CMS starts at 70% fill of the old generation.
GC logging¶
GC logging is enabled on every production server. We analyze it with GCViewer. Target metrics: minor GC under 50ms, full GC less than once per hour, total GC time under 5%.
Thread stack and monitoring¶
Reducing -Xss to 512 KB saves memory for more threads. JMX monitoring via Nagios: heap utilization, thread count, GC activity. Alert when heap exceeds 85%.
Summary¶
Xms = Xmx. CMS for web applications. GC logging always enabled. Monitor via JMX. Test under load on staging before production.
Need help with implementation?
Our experts can help with design, implementation, and operations. From architecture to production.
Contact us