Backend Development 5 min read

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

This article explains how to replace the default embedded Tomcat container in Spring Boot with Undertow, outlines the configuration steps, compares their performance and memory usage through benchmark results, and concludes that Undertow offers superior throughput for high‑concurrency Java web applications.

Architect
Architect
Architect
Replacing Tomcat with Undertow in Spring Boot: Performance and Memory Benefits

Spring Boot uses Tomcat as its default embedded servlet container, but it also supports the Undertow container, which can provide better performance and lower memory consumption. This article demonstrates how to switch from Tomcat to Undertow and why you might want to do so.

Tomcat, an Apache‑licensed lightweight servlet container, supports Servlet and JSP specifications, includes an HTTP server, and is widely adopted for Java web applications. It offers management interfaces and is completely free.

Undertow, an open‑source project from Red Hat, is written entirely in Java, supports both blocking and non‑blocking I/O, and can be embedded directly into Java applications. It fully supports Servlet and WebSocket APIs and performs exceptionally well under high‑concurrency loads.

To replace Tomcat with Undertow in a Spring Boot project, simply add the Undertow starter dependency (e.g., <dependency>...<artifactId>undertow-spring-boot-starter</artifactId>...</dependency> ) to your build file. Spring Boot will automatically configure Undertow as the embedded server, and after restarting the application the container changes to Undertow.

Benchmark tests conducted on identical hardware show that Undertow achieves higher QPS (queries per second) and consumes less memory than Tomcat. The results indicate that Undertow delivers superior throughput and efficiency, especially in high‑traffic scenarios.

In conclusion, while Spring Boot can run with either Tomcat or Undertow, Undertow is the preferred choice for high‑concurrency business systems due to its better performance and lower resource usage.

backendJavaPerformanceSpringBootTomcatUndertow
Architect
Written by

Architect

Professional architect sharing high‑quality architecture insights. Topics include high‑availability, high‑performance, high‑stability architectures, big data, machine learning, Java, system and distributed architecture, AI, and practical large‑scale architecture case studies. Open to ideas‑driven architects who enjoy sharing and learning.

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.