Backend Development 9 min read

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

This article explains how to replace Spring Boot's default embedded Tomcat container with Undertow, detailing Undertow's features, providing Maven dependency changes, and comparing performance and memory usage through test results, concluding that Undertow offers superior efficiency for high‑concurrency Java web applications.

Top Architect
Top Architect
Top Architect
Replacing Tomcat with Undertow in Spring Boot: Configuration, Features, and Performance Comparison

Spring Boot uses Tomcat as its default embedded servlet container, but it also supports Undertow, a high‑performance, lightweight web server that can be swapped in with minimal configuration.

1. Spring Boot's Tomcat Container

Tomcat is the most commonly used container in Spring Boot projects, providing an embedded servlet engine that simplifies deployment and reduces XML configuration.

2. What Is Undertow?

Undertow is a flexible, high‑performance Java web server developed by Red Hat. It supports both blocking and non‑blocking I/O (NIO), implements the Servlet 3.1 specification, and offers built‑in WebSocket support. Its lightweight design makes it ideal for embedding directly into Java applications.

High performance under load

Servlet 4.0 support

Full WebSocket (JSR‑356) support

Embedded‑only, no external container needed

Modular, chain‑handler configuration

Two core JARs, very small footprint

3. Switching Tomcat to Undertow

To replace Tomcat with Undertow, modify the Maven dependencies in your pom.xml as follows:

Remove Tomcat:

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

Add Undertow:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-undertow</artifactId>
</dependency>

After updating the dependencies, restart the application; Spring Boot will automatically use Undertow as the embedded server.

4. Tomcat vs. Undertow Performance Comparison

Benchmark tests on identical hardware show that Undertow delivers higher QPS and lower memory consumption than Tomcat under high‑concurrency workloads. The results include:

QPS: Undertow outperforms Tomcat.

Memory usage: Undertow consumes noticeably less heap.

These findings indicate that for high‑traffic services, Undertow provides better throughput and resource efficiency.

5. Conclusion

Both Tomcat and Undertow can serve as the HTTP engine in Spring Boot, but Undertow’s superior performance and lower memory footprint make it the preferred choice for high‑concurrency applications. Switching is straightforward—just adjust the Maven dependencies as shown.

Note: The article also contains promotional material for a ChatGPT community and related services, which is unrelated to the technical content.

JavaPerformanceSpringBootTomcatUndertowWebServer
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

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