Comparing Tomcat and Undertow in SpringBoot: Performance, Memory Usage, and Deployment Guide
This article explains how SpringBoot uses Tomcat by default, shows how to replace it with Undertow by adding the appropriate dependency, and presents benchmark results demonstrating Undertow's superior throughput and lower memory consumption for high‑concurrency Java web applications.
Preface
In SpringBoot the default embedded servlet container is Tomcat, but Undertow can be used as a replacement offering better performance and lower memory usage.
Tomcat Container in SpringBoot
SpringBoot is a popular Java web framework that simplifies project setup by eliminating XML configuration and providing an embedded Tomcat server for running web services.
Setting Undertow in SpringBoot
To switch from Tomcat to Undertow, add the Undertow starter dependency to the project; after rebuilding, the application runs with Undertow as the embedded server.
After configuration, the application starts with Undertow.
Why Replace Tomcat with Undertow?
Undertow, developed by Red Hat, is a lightweight, high‑performance Java web server that supports both blocking and non‑blocking I/O, servlet, and WebSocket, and generally outperforms Tomcat under high concurrency.
Tomcat vs Undertow Comparison
Benchmark results show that Undertow achieves higher QPS and lower memory consumption compared with Tomcat on the same hardware.
QPS comparison (image)
Memory usage comparison (image)
Conclusion
Both Tomcat and Undertow can serve HTTP in SpringBoot, but for high‑concurrency scenarios Undertow provides superior performance and should be considered as the preferred container.
Architecture Digest
Focusing on Java backend development, covering application architecture from top-tier internet companies (high availability, high performance, high stability), big data, machine learning, Java architecture, and other popular fields.
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.