Diagnosing and Solving a 100 ms Latency Issue in Spring Boot's Embedded Tomcat Using Arthas
This article walks through the step‑by‑step investigation of an unexpected ~100 ms latency in a Spring Boot channel service, using network checks, curl timing, and the Arthas Java diagnostic tool to pinpoint a Tomcat‑embed bug caused by Swagger jars, and then shows how upgrading Tomcat or Spring Boot resolves the problem.
The author describes a Spring Boot channel system that suffered a mysterious ~100 ms extra latency between the recorded processing time (≈150 ms) and the client‑observed response time (≈250 ms). Initial checks confirmed the network path (ping to Nginx and from Nginx to the service) was fine, but a direct curl to http://127.0.0.1:7744/send still took ~70 ms on the first request and only a few milliseconds on subsequent requests.
Because the issue could not be reproduced locally, the author turned to Arthas , Alibaba's Java diagnostic tool. Using trace on Spring MVC entry points and then on org.apache.coyote.http11.Http11Processor.service, they discovered a 129 ms hotspot inside Tomcat.
Further tracing of
org.apache.catalina.webresources.TomcatJarInputStream.createZipEntryrevealed repeated loading of JAR entries, especially the swagger‑ui resources. The watch command confirmed that Swagger’s JAR was being accessed on each request, causing the delay.
Removing the Swagger dependencies eliminated the latency, indicating a bug in the Tomcat‑embed version (2.0.2.RELEASE of Spring Boot bundles Tomcat 8.5.31). The fix is to upgrade Tomcat‑embed to 8.5.40+ or upgrade Spring Boot to a newer release where the bug is patched.
Practical solutions include:
Update tomcat.version in the Maven properties to 8.5.40 or higher.
Or upgrade the Spring Boot parent version to 2.1.0.RELEASE or later, which brings a newer Tomcat.
After the upgrade, the 100 ms latency disappears, confirming the root cause was the Tomcat‑embed bug triggered by Swagger resource loading.
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.
Java Architect Essentials
Committed to sharing quality articles and tutorials to help Java programmers progress from junior to mid-level to senior architect. We curate high-quality learning resources, interview questions, videos, and projects from across the internet to help you systematically improve your Java architecture skills. Follow and reply '1024' to get Java programming resources. Learn together, grow together.
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.
