Backend Development 8 min read

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

This article explains how to replace Spring Boot's default embedded Tomcat with the high‑performance Undertow server, detailing Undertow's features, providing Maven dependency changes, showing configuration steps, and presenting benchmark results that compare QPS and memory usage, concluding that Undertow is preferable for high‑concurrency Java backend applications.

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

Spring Boot uses Tomcat as its default embedded servlet container, but Undertow offers higher performance and lower memory usage.

What is Undertow?

Undertow is a flexible, high‑performance web server written in Java, supporting both blocking and non‑blocking (NIO) I/O, fully compatible with Servlet 3.1 and WebSocket, and is the default server for WildFly.

Features of Undertow

High performance under high concurrency.

Supports Servlet 4.0.

Full WebSocket support (JSR‑356).

Embeddable without external container.

Flexible handler chain configuration.

Lightweight, consisting of only two core JARs.

Switching Spring Boot from Tomcat to Undertow

Remove the Tomcat starter and add the Undertow starter 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 container will be Undertow.

Performance Comparison

Benchmark tests on the same machine show that Undertow achieves higher QPS and lower memory consumption than Tomcat under identical request loads.

Therefore, for high‑concurrency backend services, Undertow is the recommended choice over Tomcat.

Conclusion

Spring Boot can run either Tomcat or Undertow; switching to Undertow can significantly improve throughput and reduce memory usage in demanding scenarios.

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