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 the high‑performance Undertow container, details the configuration steps, and presents benchmark comparisons showing Undertow’s superior throughput and lower memory usage under high‑concurrency workloads.

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

Introduction

In the Spring Boot framework the default embedded container is Tomcat, but Spring Boot also supports the Undertow container, which offers better performance and lower memory usage. This article explains how to replace Tomcat with Undertow and compares the two.

Tomcat Container in Spring Boot

Spring Boot is a popular Java web framework that eliminates heavy XML configuration, allowing developers to create a complete web service within minutes. The web container is essential for running web projects; Spring Boot uses embedded Tomcat by default.

Configuring Undertow in Spring Boot

Tomcat is familiar to Java developers, but Undertow can also be used. By adding the Undertow dependency, Spring Boot can switch to Undertow as the embedded server.

After configuration, the application starts with Undertow as the container.

Why replace Tomcat with Undertow?

Comparison of Tomcat and Undertow

Tomcat is an Apache‑licensed lightweight servlet container that also includes an HTTP server. It is free and widely loved, but it differs from the Apache HTTP server 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 WebSockets and performs excellently under high concurrency.

Performance tests on identical hardware show the following results:

QPS comparison:

Tomcat

Undertow

Memory usage comparison:

Tomcat

Undertow

The tests indicate that under high‑concurrency workloads Undertow outperforms Tomcat in both throughput and memory consumption, especially since recent Undertow versions use persistent connections by default.

Conclusion

Spring Boot allows the use of either Tomcat or Undertow as the HTTP server. For high‑concurrency business systems, Undertow provides superior performance, so consider switching to it.

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.

JavaperformanceSpringBootWeb serverTomcatundertow
Java Captain
Written by

Java Captain

Focused on Java technologies: SSM, the Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading; occasionally covers DevOps tools like Jenkins, Nexus, Docker, ELK; shares practical tech insights and is dedicated to full‑stack Java development.

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.