Comparing Tomcat and Undertow in SpringBoot: Configuration, Performance, and Memory Usage
This article explains how SpringBoot defaults to an embedded Tomcat container, shows how to replace it with Undertow by adding the appropriate dependency, and compares the two servers' performance and memory consumption through benchmark results, concluding that Undertow is preferable for high‑concurrency Java backend applications.
SpringBoot uses an embedded Tomcat container by default, but it also supports the Undertow container, which can offer better performance and lower memory usage.
SpringBoot Tomcat container : Tomcat is the default lightweight servlet container in SpringBoot, providing built‑in HTTP server capabilities and easy integration.
SpringBoot setting Undertow : By adding the Undertow dependency to the project (see the dependency diagram image), developers can switch the embedded server from Tomcat to Undertow with minimal configuration.
Undertow is a flexible, high‑performance Java web server that supports both blocking and non‑blocking I/O, full servlet and WebSocket support, and excels under high concurrency.
Tomcat vs. Undertow comparison : Tomcat is a widely used servlet container with its own HTTP server, while Undertow, developed by Red Hat, is a pure Java server designed for embedding and high throughput.
Performance test results (QPS):
Undertow shows higher QPS than Tomcat under the same hardware configuration.
Memory usage comparison :
Undertow consumes less memory than Tomcat while delivering superior throughput.
Overall, for high‑concurrency business scenarios, Undertow outperforms Tomcat in both performance and memory efficiency, making it the recommended choice.
Conclusion : SpringBoot allows using either Tomcat or Undertow as the HTTP server; however, Undertow is preferable for high‑traffic applications due to its better performance and lower resource consumption.
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.