Boost SpringBoot Performance: Replace Tomcat with Undertow

This article explains why and how to replace SpringBoot's default embedded Tomcat with the high‑performance Undertow server, comparing their throughput and memory usage and showing the necessary Maven dependency and configuration steps for better scalability in Java web applications.

Java High-Performance Architecture
Java High-Performance Architecture
Java High-Performance Architecture
Boost SpringBoot Performance: Replace Tomcat with Undertow

1. Introduction

In SpringBoot, Tomcat is the most commonly used embedded container and the default choice. SpringBoot also supports the Undertow container, which offers better performance and lower memory consumption. This article explains how to switch to Undertow.

2. Tomcat container in SpringBoot

SpringBoot is a popular Java web framework that simplifies creating complete web services without heavy XML configuration, greatly improving developer productivity. A web container is essential for any web project, and Tomcat is the default embedded container in SpringBoot.

3. Setting up Undertow in SpringBoot

Most Java developers are familiar with Tomcat, but SpringBoot also allows using Undertow. To enable Undertow, simply add the Undertow dependency as shown in the image below.

After configuring, start the application and the container will be replaced by Undertow.

4. Comparison of Tomcat and Undertow

Tomcat is a lightweight servlet container under the Apache Foundation, supporting Servlets and JSP, and includes an HTTP server. However, Tomcat and Apache HTTP Server are different; the latter is written in C.

Undertow, an open‑source product from Red Hat, is written entirely in Java, supports both blocking and non‑blocking I/O, and can be embedded directly into Java projects. It fully supports Servlets and WebSocket and performs exceptionally well under high concurrency.

Performance tests on the same machine show the following results:

QPS comparison:

Tomcat

Undertow

Memory usage comparison:

Tomcat

Undertow

The tests reveal that under high concurrency, Tomcat performs weaker, while Undertow delivers superior throughput and lower memory consumption. Newer Undertow versions also use persistent connections by default, further improving concurrency handling. Therefore, Undertow is the optimal choice for high‑traffic systems.

5. Conclusion

In SpringBoot you can use either Tomcat or Undertow as the HTTP server. For high‑concurrency business scenarios, Undertow outperforms Tomcat. Switching to Undertow can significantly boost your system's performance.

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.

JavaSpringBootTomcatundertow
Java High-Performance Architecture
Written by

Java High-Performance Architecture

Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.

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.