Comparing Tomcat and Undertow in SpringBoot: Performance and Memory Usage
This article explains how SpringBoot uses Tomcat by default, demonstrates how to replace it with the high‑performance Undertow container, compares their features, and presents benchmark results showing Undertow’s superior throughput and lower memory consumption for high‑concurrency Java web applications.
Introduction
In SpringBoot the default embedded servlet container is Tomcat, which is widely used for Java web applications.
SpringBoot also supports the Undertow container, which offers better performance and lower memory usage; this article shows how to switch to Undertow.
SpringBoot’s Tomcat Container
SpringBoot is a popular Java web framework that simplifies development by eliminating XML configuration and providing an embedded Tomcat server to run web services.
Configuring Undertow in SpringBoot
To replace Tomcat with Undertow, add the Undertow starter dependency to the project. After rebuilding, the application starts with Undertow as the embedded server.
Comparison of Tomcat and Undertow
Tomcat is an Apache‑licensed lightweight servlet container that also includes an HTTP server; it is free and widely adopted.
Undertow, developed by Red Hat, is a fully Java‑based, flexible, high‑performance web server supporting both blocking and non‑blocking I/O, servlet, and WebSocket.
Benchmark Results
Performance tests on identical hardware measured QPS and memory usage. The Tomcat results are shown in the first chart, Undertow results in the second.
Undertow QPS chart:
Memory usage comparison:
The tests indicate that Undertow delivers higher throughput and uses less memory than Tomcat under high concurrency.
Conclusion
Both Tomcat and Undertow can serve HTTP in SpringBoot, but Undertow outperforms Tomcat in high‑concurrency scenarios, making it the preferred choice for performance‑critical services.
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.
