Backend Development 10 min read

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

This article explains how to replace the default embedded Tomcat container in Spring Boot with Undertow, details the configuration steps and Maven dependencies, compares performance and memory usage between the two servers, and concludes with a recommendation for high‑concurrency applications, while also promoting related AI resources and services.

Top Architect
Top Architect
Top Architect
Replacing Tomcat with Undertow in Spring Boot: Configuration, Performance Comparison, and Recommendations

In Spring Boot, Tomcat is the default embedded servlet container. The article demonstrates how to replace it with Undertow, which provides higher performance and lower memory consumption, especially for high‑concurrency scenarios.

1. SpringBoot's Tomcat container

SpringBoot is a popular Java web framework that embeds Tomcat by default, allowing developers to create a complete web service within minutes. Web containers are essential for running any web project.

2. SpringBoot setting Undertow

Undertow is a flexible, high‑performance web server written in Java, supporting both blocking and non‑blocking I/O. It is the default server for Red Hat's WildFly and can be embedded directly into Java applications.

What is Undertow? It is a Java‑based web server offering NIO non‑blocking mechanisms, full Servlet 3.1 support, and a lightweight, embeddable architecture.

Features of Undertow High performance under load. Servlet 4.0 support. Full WebSocket (JSR‑356) support. Embedded‑only, no external container required. Flexible handler chain configuration. Lightweight, consisting of two core JARs.

SpringBoot already integrates Undertow; you only need to add the Undertow dependency and exclude the default Tomcat starter.

Remove Tomcat dependency:

<code>&lt;dependency&gt;
  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
  &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
  &lt;exclusions&gt;
    &lt;exclusion&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;
    &lt;/exclusion&gt;
  &lt;/exclusions&gt;
&lt;/dependency&gt;</code>

Add Undertow dependency:

<code>&lt;dependency&gt;
  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
  &lt;artifactId&gt;spring-boot-starter-undertow&lt;/artifactId&gt;
&lt;/dependency&gt;</code>

After updating the Maven configuration and restarting the application, the embedded server switches to Undertow.

3. Tomcat vs. Undertow comparison

Tomcat is a lightweight servlet container under the Apache foundation, supporting Servlet and JSP, and includes an HTTP server. Undertow, by contrast, is a high‑performance server that supports both blocking and non‑blocking I/O, full Servlet 3.1, and WebSocket, and is fully embeddable.

Performance test (same machine configuration) shows:

QPS: Undertow outperforms Tomcat under high concurrency.

Memory usage: Undertow consumes less memory than Tomcat.

These results indicate that for high‑concurrency business systems, Undertow provides superior throughput and lower resource consumption.

4. Final recommendation

Both Tomcat and Undertow can serve HTTP requests in SpringBoot, but Undertow delivers better performance in high‑traffic scenarios. Switching to Undertow can significantly improve system efficiency.

Promotional note: The author also offers AI‑related resources, including a DeepSeek practical collection, ChatGPT accounts, and a paid knowledge‑sharing community. Interested readers can follow the provided links or scan QR codes to obtain the offers.

© Content sourced from the internet; original copyright belongs to the author.

backendJavaPerformanceSpringBootTomcatUndertow
Top Architect
Written by

Top Architect

Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.

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.