Backend Development 9 min read

Switching Spring Boot's Embedded Server from Tomcat to Undertow: Benefits and Configuration Guide

This article explains how to replace Spring Boot's default embedded Tomcat server with Undertow, detailing Undertow's features, Maven dependency changes, performance and memory benchmarks, and provides step‑by‑step configuration code to improve high‑concurrency Java web applications.

Top Architect
Top Architect
Top Architect
Switching Spring Boot's Embedded Server from Tomcat to Undertow: Benefits and Configuration Guide

Spring Boot uses Tomcat as its default embedded servlet container, but Undertow offers higher performance and lower memory usage. This guide introduces Undertow, its characteristics, and why it may be a better choice for high‑concurrency systems.

1. Spring Boot's Tomcat Container

Tomcat is the most commonly used web container in Spring Boot, providing an embedded HTTP server that simplifies application deployment.

2. Setting Up Undertow in Spring Boot

Undertow is a flexible, high‑performance Java web server supporting both blocking and non‑blocking I/O, and fully compatible with Servlet 3.1. It is the default server for WildFly.

What is Undertow? A lightweight, embeddable web server written in Java, offering NIO‑based non‑blocking mechanisms and a builder‑style API.

Key Features High performance under load Servlet 4.0 support Full WebSocket (JSR‑356) support Embedded design – no external container needed Modular and lightweight (two core JARs)

To use Undertow, replace the Tomcat starter with Undertow in the Maven pom.xml :

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-web</artifactId>
  <exclusions>
    <exclusion>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-tomcat</artifactId>
    </exclusion>
  </exclusions>
</dependency>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-undertow</artifactId>
</dependency>

After rebuilding, the application runs with Undertow as the embedded server.

3. Tomcat vs. Undertow Performance Comparison

Benchmark tests on identical hardware show Undertow achieving higher QPS and lower memory consumption than Tomcat, especially under high concurrency.

Images (omitted) illustrate the QPS and memory usage results, confirming Undertow's superiority for demanding workloads.

4. Conclusion

Both Tomcat and Undertow can serve HTTP requests in Spring Boot, but Undertow provides better performance and resource efficiency for high‑traffic applications. Switching to Undertow can significantly improve system throughput.

JavaperformanceSpringBootWeb ServerTomcatUndertow
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.