Replacing Tomcat with Undertow in Spring Boot: Configuration, Features, and Performance Comparison
This article explains how Spring Boot uses Tomcat by default, introduces Undertow as a high‑performance alternative, provides step‑by‑step Maven configuration to switch containers, compares Tomcat and Undertow on throughput and memory usage, and recommends Undertow for high‑concurrency Java web applications.
Spring Boot ships with an embedded Tomcat server as its default web container, but it also supports the high‑performance Undertow server, which can be swapped in with minimal configuration.
1. Spring Boot's Tomcat Container
Tomcat is the most widely used servlet container in Spring Boot projects, offering an embedded solution that simplifies deployment and reduces XML configuration.
2. Setting Up Undertow in Spring Boot
Undertow is a flexible, high‑performance Java web server developed by Red Hat, supporting both blocking and non‑blocking I/O, full Servlet 3.1 compatibility, and WebSocket (JSR‑356). Its lightweight, embeddable design makes it ideal for microservices.
High performance under load
Servlet 4.0 support
Full WebSocket support
Embedded‑only, no external container needed
Modular, chain‑handler configuration
Lightweight, consisting of two core JARs
To replace Tomcat with Undertow, remove the default Tomcat starter and add the Undertow starter in the Maven pom.xml :
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>Then add the Undertow dependency:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>After rebuilding and starting the application, Spring Boot will run with Undertow instead of Tomcat.
3. Tomcat vs. Undertow Comparison
Tomcat is a mature, lightweight servlet container that also includes an HTTP server, but it lacks some of the non‑blocking capabilities of Undertow. In benchmark tests on identical hardware, Undertow demonstrates higher QPS and lower memory consumption, especially under high concurrency.
Test results show that Undertow outperforms Tomcat in both request throughput and memory usage, and newer Undertow versions enable persistent connections by default, further improving throughput.
4. Conclusion
For high‑traffic Java web services, replacing Tomcat with Undertow can significantly improve performance and reduce resource usage, making Undertow the preferred choice in demanding environments.
Top Architect
Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn 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.