Backend Development 6 min read

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

This article explains how to replace the default embedded Tomcat container in Spring Boot with Undertow, compares their performance and memory usage through load tests, and demonstrates why Undertow is a better choice for high‑concurrency Java web applications.

Selected Java Interview Questions
Selected Java Interview Questions
Selected Java Interview Questions
Replacing Tomcat with Undertow in Spring Boot: Performance and Memory Comparison

Introduction

In the SpringBoot framework the most commonly used container is Tomcat, which is the default embedded container.

SpringBoot also supports the Undertow container, which can replace Tomcat and offers better performance and lower memory usage; this article explains how to use Undertow.

Tomcat Container in SpringBoot

SpringBoot is currently the most popular Java web framework. It frees developers from heavy XML configuration, allowing a complete web service to be created in minutes, greatly improving productivity.

Web container technology is essential for any web project because the project must run inside a container. In SpringBoot the default embedded container is Tomcat.

Configuring Undertow in SpringBoot

Java developers are familiar with Tomcat, the most common web application container. Besides Tomcat, SpringBoot can also use Undertow by adding its dependency, as shown in the following diagram.

After configuration, running the application shows that the container has been switched to Undertow.

Why 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 and offers management features, but it is written in Java and differs from Apache HTTP Server written in C.

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

We performed load tests on the same machine for Tomcat and Undertow. The results are shown below.

QPS Test Results Comparison:

Tomcat

Undertow

Memory Usage Comparison:

Tomcat

Undertow

The tests show that under high‑concurrency scenarios Tomcat is relatively weaker. With equal request loads, Undertow delivers better performance and lower memory consumption, and its newer versions use persistent connections, further improving throughput. Therefore Undertow is the optimal choice for high‑concurrency business systems.

Conclusion

In SpringBoot you can use either Tomcat or Undertow as the HTTP server. Undertow outperforms Tomcat in high‑concurrency scenarios, so consider switching to Undertow to significantly improve system performance.

JavaperformanceSpringBootTomcatUndertowWebContainer
Selected Java Interview Questions
Written by

Selected Java Interview Questions

A professional Java tech channel sharing common knowledge to help developers fill gaps. Follow us!

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.