Backend Development 6 min read

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

This article explains how to replace Spring Boot's default embedded Tomcat with the Undertow container, details the configuration steps, and presents benchmark results showing Undertow's superior throughput and lower memory usage under high‑concurrency workloads, making it a better choice for performance‑critical applications.

Architect's Tech Stack
Architect's Tech Stack
Architect's Tech Stack
Replacing Tomcat with Undertow in Spring Boot: Configuration and Performance Comparison

Hello everyone, I'm Peng Lei.

In the Spring Boot framework, the most commonly used container is Tomcat, which is the default embedded container. Spring Boot also supports the Undertow container, which can be easily swapped in place of Tomcat and offers better performance and lower memory consumption. This article will explain how to use Undertow.

Tomcat Container in Spring Boot

Spring Boot is currently the most popular Java web framework. It frees developers from heavy XML configuration, allowing a complete web service to be created within minutes, greatly improving development efficiency. Web container technology is essential for any web project, and Tomcat is the default embedded container used most often in Spring Boot.

Configuring Undertow in Spring Boot

Java developers are very familiar with Tomcat as the most common web application container. Besides Tomcat, Spring Boot also supports the Undertow container. By simply adding the Undertow dependency, you can replace Tomcat with Undertow, as shown in the following diagram.

After configuring the dependency, when the application starts the container is replaced by Undertow.

Why should we replace Tomcat with Undertow?

Comparison of Tomcat and Undertow

Tomcat is a lightweight servlet container under the Apache Foundation, supporting Servlets and JSP. It includes an HTTP server, so it can also function as a standalone web server. However, Tomcat is written in Java, while Apache HTTP Server is a separate C‑based server. Tomcat is free and widely loved by developers.

Undertow is an open‑source product from Red Hat. It is written entirely in Java, offering a flexible high‑performance web server that supports both blocking and non‑blocking I/O. Because it is Java‑based, it can be embedded directly into Java projects, fully supports Servlets and WebSockets, and performs exceptionally well under high concurrency.

We conducted performance tests comparing Tomcat and Undertow on the same machine configuration. The results are shown below.

QPS Test Result Comparison:

Tomcat

Undertow

Memory Usage Comparison:

Tomcat

Undertow

Test findings indicate that under high‑concurrency scenarios, Tomcat performs relatively weaker. With identical hardware and request load, Undertow delivers superior performance and lower memory consumption. Moreover, the latest Undertow version uses persistent connections by default, further improving throughput, making it the optimal choice for high‑concurrency business systems.

Conclusion

In Spring Boot, you can use Tomcat as the HTTP service or replace it with Undertow. Undertow outperforms Tomcat in high‑concurrency business scenarios. Therefore, for systems handling high request volumes, consider using Undertow to achieve significant performance gains.

JavaperformanceSpring BootWeb ServerTomcatUndertow
Architect's Tech Stack
Written by

Architect's Tech Stack

Java backend, microservices, distributed systems, containerized programming, and more.

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.