Why Switch to Undertow? Boost SpringBoot Performance Over Tomcat
This article explains how to replace SpringBoot's default embedded Tomcat with Undertow, details the configuration steps, compares their performance and memory usage through benchmark results, and argues that Undertow offers superior throughput for high‑concurrency Java web applications.
Introduction
In SpringBoot the most used container is Tomcat, the default embedded container. SpringBoot also supports Undertow, which offers better performance and lower memory usage. This article explains how to use Undertow.
Tomcat Container in SpringBoot
SpringBoot is a popular Java web framework that eliminates heavy XML configuration, allowing developers to create a complete web service within minutes. The web container is essential; Tomcat is the default embedded container.
Configuring Undertow in SpringBoot
Besides Tomcat, SpringBoot can use Undertow by adding its dependency. After configuration, the application starts with Undertow as the container.
After configuration, launching the application shows that the container has been replaced by Undertow.
Why replace Tomcat with Undertow?
Comparison of Tomcat and Undertow
Tomcat is an Apache lightweight servlet container supporting Servlet and JSP, includes an HTTP server, and is free, making it popular among developers. Undertow, from Red Hat, is a flexible high‑performance web server written in Java, supporting both blocking and non‑blocking I/O, fully compatible with Servlet and WebSocket, and excels under high concurrency.
Benchmark Results
We performed load tests on the same machine. The QPS and memory usage comparisons are shown below.
Tomcat
Undertow
Tomcat Memory
Undertow Memory
Test results indicate that in high‑concurrency scenarios Undertow outperforms Tomcat in both performance and memory consumption, and its default use of persistent connections further improves throughput.
Conclusion
SpringBoot can use either Tomcat or Undertow for HTTP services. For high‑concurrency business systems, Undertow provides better performance, so consider switching to achieve significant improvements.
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 High-Performance Architecture
Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.
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.
