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.

Top Architect
Top Architect
Top Architect
Using Undertow as an Alternative to Tomcat in Spring Boot

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.

Undertow startup screenshot
Undertow startup screenshot

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.

Tomcat QPS
Tomcat QPS
Undertow QPS
Undertow QPS
Tomcat memory
Tomcat memory
Undertow memory
Undertow memory

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.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavaWeb serverTomcatundertow
Top Architect
Written by

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.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.