Skip to content
Go back

Tomcat, Jetty, or Undertow: Choosing a Java Web Server

Published:  at  11:17 AM

Choosing a Java web server is rarely a matter of finding the fastest name on a benchmark. The relevant questions are usually more concrete: which APIs the application needs, whether request handling is blocking or asynchronous, how the server is embedded and configured, and what the deployment environment already standardizes.

Tomcat, Jetty, and Undertow can all serve HTTP traffic and can be embedded in a Java application. They differ in defaults, integration details, and the trade-offs around servlet compatibility, non-blocking I/O, operational familiarity, and application architecture. This article compares those trade-offs without treating a server choice as a universal performance ranking.

1. Apache Tomcat

What it is

[SOURCE FACT] Tomcat is a widely used servlet container from the Apache Software Foundation. It supports the Servlet API and JSP, and is a common default in Spring Boot applications that use spring-boot-starter-web.

[ANALYSIS] Tomcat is a conservative default when the application is built around the servlet programming model, conventional MVC, or existing operational knowledge of Tomcat configuration. Its connector is not inherently “one thread per connection”: with a non-blocking connector, a small set of threads can manage connections while worker threads process requests. The actual behavior depends on the connector and executor configuration.

Strengths

Constraints

Good fit

Tomcat is a sensible choice for servlet-based MVC applications, JSP applications, and small-to-medium REST services when compatibility and operational familiarity matter more than changing the programming model.

2. Jetty

What it is

[SOURCE FACT] Jetty is a lightweight HTTP server and servlet container associated with the Eclipse Foundation. It supports non-blocking I/O, asynchronous servlet APIs, embedded deployment, and protocols such as HTTP/2 and WebSocket when configured and supported by the relevant stack.

[ANALYSIS] Jetty is attractive when the server is part of the application rather than a separately managed runtime. Its flexibility is useful, but it also means that thread pools, connection limits, queues, and protocol settings need to be reviewed as one system. “Lightweight” does not remove the cost of blocking work in the application.

Strengths

Constraints

Good fit

Jetty fits REST services, microservices, embedded applications, and systems that need asynchronous handling or WebSocket/HTTP/2 support without adopting a different server architecture by default.

3. Undertow

What it is

[SOURCE FACT] Undertow is a lightweight HTTP server designed for embedded use and non-blocking I/O. It is associated with the WildFly/JBoss ecosystem and can serve servlet-based applications as well as lower-level HTTP handlers.

[ANALYSIS] Undertow’s handler model makes it a good option for applications that want explicit control over non-blocking request processing. It is not automatically a reactive framework, and it does not make blocking application code non-blocking. Spring WebFlux compatibility, if needed, must be checked for the chosen Spring Boot and Undertow versions; a server choice alone does not establish a reactive architecture.

Strengths

Constraints

Good fit

Undertow is a candidate for embedded services, REST APIs, and applications using non-blocking handlers. It is a poor fit when JSP compatibility is a requirement. For reactive applications, evaluate the complete framework and dependency stack rather than selecting Undertow on the label “reactive.”

4. Comparison

The table describes general tendencies, not guarantees. Defaults and available features vary by server version, connector, framework, and deployment configuration.

CriterionTomcatJettyUndertow
Request handlingServlet worker model; non-blocking connectors are availableServlet worker model plus asynchronous and non-blocking APIsNon-blocking handlers plus servlet support
Memory footprintModerate in a typical servlet deployment; measure the applicationOften compact in embedded deployments; measure the applicationOften compact in embedded deployments; measure the application
StartupDepends on application and configurationOften fast in embedded deploymentsOften fast in embedded deployments
HTTP/2Available with the appropriate connector and configurationAvailable with the appropriate configurationAvailable with the appropriate configuration
EmbeddingSupportedA strong use caseA strong use case
JSPSupportedAvailable with the required JSP integrationNot supported
Reactive framework fitDepends on the framework and adapterDepends on the framework and adapterDepends on the framework and adapter

5. How to choose

[PROPOSED DESIGN] Use the following decision process rather than starting with a generic performance claim:

6. Conclusion

Tomcat is usually the least surprising choice for servlet and JSP applications. Jetty is a flexible embedded server with strong asynchronous capabilities. Undertow provides an embeddable non-blocking handler model and is a reasonable candidate for services that need that level of control.

None of these servers is universally fastest. The outcome depends on blocking behavior, executor and connection-pool limits, downstream latency, protocol configuration, and the framework around the server. Establish the application requirements first, then validate the shortlist with production-like load and operational checks.


Share this post on:

Previous Post
High-Load System Design: Managing Traffic Spikes End to End
Next Post
Project Loom and Virtual Threads in Java