Backend Development 13 min read

Diagnosing and Solving a 100ms Latency Issue in Spring Boot Embedded Tomcat Using Arthas

This article details how a hidden 100 ms delay in a Spring Boot channel system was traced to Tomcat‑embed’s handling of Swagger‑UI resources, diagnosed with Arthas, and resolved by upgrading the embedded Tomcat version.

Code Ape Tech Column
Code Ape Tech Column
Code Ape Tech Column
Diagnosing and Solving a 100ms Latency Issue in Spring Boot Embedded Tomcat Using Arthas

Background: A channel system built with Spring Boot and embedded Tomcat exhibited an unexplained ~100 ms latency between the time logged inside the application and the response time observed by the client.

Initial investigation ruled out business logic, filters, and network issues by pinging the Nginx host and the Tomcat server and by sending direct requests to localhost , which still showed a 70 ms delay on the first request and a normal 3 ms on subsequent requests.

Arthas, Alibaba’s Java diagnostic tool, was employed to trace the execution path. The trace command on Spring MVC indicated that the MVC layer only consumed about 18 ms, leaving the majority of the latency unaccounted for.

Further tracing of org.apache.catalina.webresources.TomcatJarInputStream revealed repeated calls to createZipEntry() , which loaded META‑INF resources from JAR files. Using the watch command showed that the loaded resource was swagger‑ui , a Swagger UI library bundled with the project.

Removing the Swagger dependencies eliminated the extra 70 ms, indicating a bug in the Tomcat‑embed version (8.5.31) that re‑loads static resources on each request when the cache expires.

The fix is to upgrade the embedded Tomcat version to 8.5.40 or later (or upgrade Spring Boot to 2.1.0+), which contains the corrected implementation of org.apache.catalina.mapper.Mapper#internalMapWrapper and proper caching of static resources.

debuggingJavaperformanceSpring BootTomcatArthasSwagger
Code Ape Tech Column
Written by

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

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.