Using Undertow as an Alternative to Tomcat in Spring Boot
This article explains how Spring Boot’s default embedded Tomcat container can be replaced with the high‑performance Undertow server, provides step‑by‑step Maven configuration, compares their performance and memory usage, and concludes with a recommendation for high‑concurrency applications while also containing promotional material for AI services.
In this tutorial the author, a senior architect, introduces Spring Boot’s default embedded Tomcat container and shows how to replace it with the high‑performance Undertow server.
1. Spring Boot’s Tomcat Container
Spring Boot is a popular Java web framework that uses Tomcat as its default embedded servlet container, simplifying project setup and deployment.
2. Setting Up Undertow in Spring Boot
Undertow is a flexible, high‑performance web server written in Java, supporting both blocking and non‑blocking I/O, fully compatible with Servlet 4.0, WebSocket, and designed for embedded use.
High performance under load
Supports Servlet 4.0
Full WebSocket support (JSR‑356)
Embedded – no external container needed
Lightweight, composed of two core JARs
Highly flexible handler chain configuration
To switch to Undertow, modify the Maven dependencies as follows:
<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>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>After updating the dependencies and restarting the application, the embedded server is now Undertow.
3. Tomcat vs. Undertow Comparison
Both servers are lightweight servlet containers, but Undertow offers superior performance and lower memory consumption under high concurrency. The article includes benchmark images showing QPS and memory usage for each server.
The tests show that Undertow consistently outperforms Tomcat in both throughput and memory usage, especially in high‑concurrency scenarios.
4. Final Remarks
Spring Boot can run either Tomcat or Undertow as its HTTP server. For high‑traffic applications, Undertow provides better performance and lower resource consumption, making it a recommended choice.
After the technical tutorial, the article also contains promotional sections advertising AI tools, a paid community offering ChatGPT accounts, training materials, and other commercial services.
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.