Replacing Tomcat with Undertow in SpringBoot: Performance and Memory Comparison
This article explains how to replace the default embedded Tomcat container in SpringBoot with Undertow, compares their performance and memory usage through benchmark tests, and recommends Undertow for high‑concurrency Java web applications.
Introduction
In the SpringBoot framework, Tomcat is the most commonly used embedded container, but SpringBoot also supports Undertow, which offers better performance and lower memory consumption. This article demonstrates how to switch to Undertow and evaluates its advantages.
Tomcat Container in SpringBoot
SpringBoot is a popular Java web framework that simplifies project setup by eliminating extensive XML configuration, allowing developers to create a complete web service within minutes. As a core component, a web container is required to run the application, and Tomcat is the default embedded container.
Configuring Undertow in SpringBoot
While most Java developers are familiar with Tomcat, SpringBoot also allows the use of Undertow by simply adding the Undertow dependency. After adding the dependency (as shown in the accompanying image), the application can be started and the embedded container will be replaced by Undertow.
Undertow, an open‑source product from Red Hat, is a flexible high‑performance web server written entirely in Java. It supports both blocking and non‑blocking I/O, can be embedded directly into Java projects, and fully supports Servlet and WebSocket, making it excel under high concurrency.
Tomcat vs. Undertow: Performance and Memory Comparison
Benchmark tests were conducted on the same machine configuration to compare QPS (queries per second) and memory usage between Tomcat and Undertow. The results show that Undertow achieves higher QPS and consumes less memory than Tomcat.
Because Undertow’s newer versions use persistent connections by default, its throughput under high‑concurrency scenarios is further improved, making it the optimal choice for systems with heavy request loads.
Conclusion
Both Tomcat and Undertow can serve HTTP requests in SpringBoot, but Undertow delivers superior performance and lower memory usage in high‑concurrency business scenarios. For applications that expect a large number of simultaneous requests, switching to Undertow can significantly boost system performance.
Selected Java Interview Questions
A professional Java tech channel sharing common knowledge to help developers fill gaps. Follow us!
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.