Why Switch from Tomcat to Undertow in SpringBoot? Performance & Memory Benefits
This article explains how to replace SpringBoot's default Tomcat container with Undertow, details the configuration steps, compares their performance and memory usage through benchmark results, and concludes that Undertow offers superior throughput for high‑concurrency Java web applications.
Introduction
In the SpringBoot framework, Tomcat is the default embedded container, but SpringBoot also supports Undertow, which offers better performance and lower memory usage.
Tomcat Container in SpringBoot
SpringBoot is a popular Java web framework that lets developers create a complete web service within minutes, freeing them from heavy XML configuration. Web container technology is essential for any web project, and Tomcat is the most commonly used container.
Configuring Undertow in SpringBoot
To replace Tomcat with Undertow, simply add the Undertow dependency to the project. After adding the dependency and rebuilding, the application starts with Undertow as the embedded server.
Tomcat vs Undertow Comparison
Tomcat is an Apache lightweight servlet container that supports Servlet and JSP, includes an HTTP server, and is free. Undertow, developed by Red Hat, is a flexible high‑performance Java web server that supports blocking and non‑blocking I/O, embeds easily, and fully supports Servlet and WebSocket.
Performance Test Results
Under identical machine configurations, QPS and memory usage were measured. The results show that Undertow achieves higher QPS and lower memory consumption than Tomcat, especially under high concurrency. Undertow’s newer versions also use persistent connections by default, further improving throughput.
Conclusion
Both Tomcat and Undertow can serve HTTP in SpringBoot, but Undertow outperforms Tomcat in high‑concurrency scenarios. For systems with heavy request loads, switching to Undertow can significantly boost performance.
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 Backend Technology
Focus on Java-related technologies: SSM, Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading. Occasionally cover DevOps tools like Jenkins, Nexus, Docker, and ELK. Also share technical insights from time to time, committed to Java full-stack development!
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.
