Skip to content
Replacing Tomcat with Undertow in Spring Boot: Configuration, Performance Comparison, and Benefits

Replacing Tomcat with Undertow in Spring Boot: Configuration, Performance Comparison, and Benefits

This article explains how to replace Spring Boot's default embedded Tomcat container with Undertow, provides the necessary Maven configuration, compares their performance and memory usage, and highlights why Undertow is a superior choice for high‑concurrency Java web applications.

Java Architect Essentials
Java Architect Essentials
Java Architect Essentials

Spring Boot uses Tomcat as its default embedded servlet container, but it also supports Undertow, a high‑performance, lightweight web server.

Undertow, developed by Red Hat, offers non‑blocking NIO, full Servlet 3.1/4.0 support, WebSocket, and can be embedded directly into Java applications.

Key features of Undertow include high concurrency performance, Servlet 4.0 support, full WebSocket (JSR‑356) support, embedded operation without a separate container, flexible handler chains, and a small footprint consisting of two core JARs.

To switch Spring Boot from Tomcat to Undertow, remove the Tomcat starter dependency and add the Undertow starter dependency in 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>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-undertow</artifactId>
</dependency>

After rebuilding and starting the application, the embedded server changes to Undertow.

Benchmark tests on the same hardware show that Undertow achieves higher QPS and lower memory consumption than Tomcat under high concurrency, making it a better choice for performance‑critical services.

In conclusion, while Spring Boot can run with either Tomcat or Undertow, Undertow provides superior performance and resource efficiency for high‑traffic applications.

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.

JavaperformanceSpringBootTomcatUndertow
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.