Replacing Tomcat with Undertow in Spring Boot: Performance and Memory Comparison
This article explains how to replace Spring Boot's default embedded Tomcat with Undertow, outlines the configuration steps, compares their performance and memory usage through benchmark results, and concludes that Undertow offers superior throughput and lower resource consumption for high‑concurrency Java web applications.
Hello, I'm Lei.
Spring Boot's Default Tomcat Container
Spring Boot is currently the most popular Java web framework, allowing developers to create a complete web service within minutes without cumbersome XML configuration. By default, it embeds the Tomcat servlet container to run web applications.
Configuring Undertow in Spring Boot
Besides Tomcat, Spring Boot also supports the Undertow container. To switch, you only need to add the Undertow dependency to your project, as shown in the accompanying diagram.
After adding the dependency and rebuilding, the application starts with Undertow instead of Tomcat.
Why Replace Tomcat with Undertow?
Undertow, an open‑source product from Red Hat, is written entirely in Java, supports both blocking and non‑blocking I/O, and can be embedded directly into Java projects. It fully supports Servlet and WebSocket APIs and demonstrates excellent performance under high concurrency.
Tomcat vs. Undertow: Advantages Comparison
Tomcat, an Apache‑funded lightweight servlet container, includes an HTTP server and offers management tools, but it is generally less efficient for high‑throughput scenarios.
Undertow is a flexible, high‑performance web server that excels in both QPS and memory usage, especially when handling many simultaneous connections.
QPS Test Results
Tomcat
Undertow
Memory Usage Comparison
Tomcat
Undertow
Benchmark results show that under identical hardware, Undertow delivers higher QPS and lower memory consumption than Tomcat, making it the optimal choice for high‑concurrency business systems.
Conclusion
Spring Boot allows you to use either Tomcat or Undertow as the HTTP server. For high‑traffic applications, Undertow provides better performance and resource efficiency, so switching to Undertow can significantly improve system throughput.
Architect's Tech Stack
Java backend, microservices, distributed systems, containerized programming, and more.
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.