Why Switch SpringBoot’s Default Tomcat to Undertow? Performance & Memory Gains Explained

This article explains how to replace SpringBoot's default embedded Tomcat with the high‑performance Undertow server, details the necessary Maven changes, compares Tomcat and Undertow in terms of throughput and memory usage, and concludes why Undertow is the better choice for high‑concurrency Java web applications.

Top Architect
Top Architect
Top Architect
Why Switch SpringBoot’s Default Tomcat to Undertow? Performance & Memory Gains Explained

Hello, I am a senior architect. In the SpringBoot framework, Tomcat is the most commonly used and default embedded container. SpringBoot also supports the Undertow container, which offers better performance and lower memory usage than Tomcat. This article explains how to use Undertow.

1 SpringBoot中的Tomcat容器

SpringBoot is currently the most popular Java web framework. It allows developers to create a complete web service within minutes, greatly improving development efficiency. The web container is essential for any web project, and SpringBoot uses Tomcat as its default embedded container.

2 SpringBoot设置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 WildFly and is designed for embedding. Key features include high performance under load, Servlet 4.0 support, full WebSocket support, lightweight embedded deployment, chainable handlers, and a minimal core consisting of two JARs.

What is Undertow?

Undertow’s characteristics: high performance, Servlet 4.0 support, WebSocket support, embedded, flexible, lightweight.

SpringBoot has full integration with Undertow; only the dependencies need to be changed.

<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 pom and restarting the application, the embedded server switches from Tomcat to Undertow.

3 Tomcat与Undertow的优劣对比

Tomcat is an Apache‑licensed lightweight servlet container that also includes an HTTP server. Undertow, developed by Red Hat, offers both blocking and non‑blocking I/O, full Servlet support, and WebSocket support, and can be embedded directly into Java projects.

Benchmark tests on identical hardware show that Undertow achieves higher QPS and lower memory consumption than Tomcat under high concurrency.

The results indicate that for high‑concurrency business systems, Undertow outperforms Tomcat in both throughput and memory usage, especially since recent versions use persistent connections by default.

4 最后

In SpringBoot you can use either Tomcat or Undertow as the HTTP server. For high‑concurrency scenarios, Undertow provides superior performance, so consider switching to it to achieve significant gains.

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.

JavaSpringBootWeb 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

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.