Replacing Tomcat with Undertow in SpringBoot: Configuration, Features, and Performance Comparison
This article explains how SpringBoot's default Tomcat container can be swapped for the high‑performance Undertow server, details Undertow's characteristics, provides Maven configuration steps with code snippets, and presents benchmark results showing superior throughput and lower memory usage for high‑concurrency applications.
In SpringBoot, Tomcat is the default embedded servlet container, but Undertow offers higher performance and lower memory consumption, making it a compelling alternative for high‑concurrency services.
Undertow is a flexible, high‑performance Java web server supporting both blocking and non‑blocking I/O, fully compatible with Java EE Servlet 3.1, and serves as the default server for Red Hat's WildFly.
To replace Tomcat with Undertow, remove the Tomcat starter from the SpringBoot dependencies and add the Undertow starter. The required Maven snippets are:
<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 updating the dependencies and restarting the application, the embedded server switches to Undertow. Benchmark tests on identical hardware show that Undertow achieves higher QPS and consumes less memory than Tomcat, especially under heavy load, and it enables persistent connections by default.
Therefore, for applications with high request volumes, adopting Undertow in SpringBoot can significantly improve performance and resource efficiency.
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.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.