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

This article explains how to replace Spring Boot's default embedded Tomcat with Undertow, details the configuration steps, compares their performance and memory usage through benchmark results, and concludes that Undertow offers superior efficiency for high‑concurrency Java backend applications.

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

Preface

In the Spring Boot framework, Tomcat is the most commonly used container and the default embedded servlet 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 explains 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. A web container is essential for any web project, and in Spring Boot the default embedded container is Tomcat.

Setting Up Undertow in Spring Boot

Tomcat is familiar to most Java developers as the most widely used servlet container. Besides Tomcat, Spring Boot can also use Undertow. By simply adding the Undertow dependency, the embedded container is switched to Undertow.

After configuring the dependency and rebuilding the project, the application starts with Undertow as the embedded container.

Why replace Tomcat with Undertow?

Comparison of Tomcat and Undertow

Tomcat, an Apache Foundation lightweight servlet container, supports Servlets and JSPs and includes an HTTP server. It is free and widely loved by developers, but it is written in Java and differs from the Apache HTTP server written in C.

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

Benchmark Results

QPS comparison:

Tomcat

Undertow

Memory usage comparison:

Tomcat

Undertow

The tests show that under high‑concurrency workloads, Tomcat performs weaker than Undertow. With the same hardware, Undertow delivers better throughput and lower memory consumption, and its newer versions use persistent connections by default, further improving concurrency handling. Therefore, Undertow is the preferred choice for high‑traffic backend systems.

Conclusion

Spring Boot allows you to use either Tomcat or Undertow as the HTTP server. In high‑concurrency scenarios, Undertow outperforms Tomcat. If your system faces heavy request loads, consider switching to Undertow to achieve significant performance gains.

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.

BackendjavaperformanceSpring BootWeb serverTomcatundertow
Architecture Digest
Written by

Architecture Digest

Focusing on Java backend development, covering application architecture from top-tier internet companies (high availability, high performance, high stability), big data, machine learning, Java architecture, and other popular fields.

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.