Why Switch to Undertow in Spring Boot? Performance and Memory Gains Over Tomcat

This article explains how to replace Spring Boot's default embedded Tomcat with Undertow, compares their architectures, presents benchmark results showing Undertow's superior throughput and lower memory usage, and concludes that Undertow is the better choice for high‑concurrency Java web applications.

ITPUB
ITPUB
ITPUB
Why Switch to Undertow in Spring Boot? Performance and Memory Gains Over Tomcat

Introduction

Spring Boot ships with an embedded Tomcat server as its default servlet container. Undertow is a high‑performance, non‑blocking Java web server that can be used as an alternative, often providing better throughput and lower memory consumption.

Configuring Undertow in Spring Boot

Replace Tomcat by adding the Undertow starter dependency to the project and rebuilding the application. After the rebuild, Spring Boot starts with Undertow as the HTTP server.

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-undertow</artifactId>
</dependency>

For Gradle projects:

implementation 'org.springframework.boot:spring-boot-starter-undertow'

Why Use Undertow

Fully written in Java, allowing direct embedding in Java applications.

Supports both blocking and non‑blocking I/O.

Provides native support for Servlet, JSP, and WebSocket.

Consumes less heap memory under load.

Higher queries‑per‑second (QPS) performance in high‑concurrency scenarios.

Tomcat vs. Undertow

Tomcat : Apache‑sponsored lightweight servlet container, includes an HTTP server, extensive management tools, but uses a thread‑per‑request model.

Undertow : Red Hat’s open‑source server, flexible architecture, uses an event‑driven, non‑blocking model, and defaults to persistent connections in recent versions.

Benchmark Results

Performance tests on identical hardware show that Undertow delivers higher QPS and lower memory usage than Tomcat under the same load.

QPS – Tomcat

QPS – Undertow

Memory Usage – Tomcat

Memory Usage – Undertow

Conclusion

For high‑concurrency business systems, Undertow provides superior throughput and lower memory consumption compared with Tomcat, making it the preferred embedded server for Spring Boot applications.

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.

JavaperformanceSpring BootWeb serverTomcatundertow
ITPUB
Written by

ITPUB

Official ITPUB account sharing technical insights, community news, and exciting events.

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.