Spring Boot Tomcat and JVM Optimization, Remote Debugging, and JConsole/JVisualVM Remote Connection Guide
This article explains how to optimize Spring Boot's embedded Tomcat settings, tune JVM parameters, configure remote debugging in IDEA, and connect to JVM tools like JConsole and JVisualVM remotely, while also providing practical code snippets and deployment tips for backend services.
Spring Boot web projects use an embedded Tomcat server by default, which can also be switched to Jetty; the embedded approach simplifies micro‑service deployment and eliminates the need to download external servers.
Key optimization points include configuring thread numbers, connection timeout, and JVM settings to improve stability and performance under load.
In application.yml you can set Tomcat parameters as follows:
server:
tomcat:
min-spare-threads: 20
max-threads: 100
connection-timeout: 5000JVM optimization typically involves using the -server mode and adjusting heap sizes with -Xms and -Xmx . Example launch commands:
java -server -jar springboot-1.0.jar java -server -Xms512m -Xmx768m -jar springboot-1.0.jarFor remote debugging, start the application with debug options:
java -Djavax.net.debug=ssl -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8888 -jar springboot-1.0.jarAfter launching, configure IDEA's Remote Debug configuration (set project name, IP address, and port) and ensure the server firewall allows the connection.
To monitor the JVM remotely with JConsole or JVisualVM, first verify the server's hostname using hostname -i , update /etc/hosts to map the correct IP, and restart the server. Then start the Java process with JMX options:
java -jar -Djava.rmi.server.hostname=192.168.44.128 \
-Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.port=911 \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.authenticate=false \
jantent-1.0-SNAPSHOT.jarOpen JConsole, enter the IP and port (e.g., 192.168.44.128:911) to connect; the same parameters work for JVisualVM, providing richer monitoring capabilities.
The article concludes with promotional information about the author's other technical columns and free resources, encouraging readers to follow the public account for additional materials.
Code Ape Tech Column
Former Ant Group P8 engineer, pure technologist, sharing full‑stack Java, job interview and career advice through a column. Site: java-family.cn
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.