Tomcat vs. Jetty vs. Undertow: The Ultimate 2025 Guide
Choosing between Tomcat, Jetty, and Undertow in 2025? Our ultimate guide compares performance, memory, and use cases to help you pick the best Java server.
David Kowalski
Senior Java Architect specializing in high-performance, scalable backend systems and microservices.
Introduction: The Battle for Java's Backend
In the world of Java web development, the choice of a servlet container or web server is one of the most foundational decisions you'll make. It directly impacts your application's performance, scalability, memory footprint, and even developer productivity. For years, three names have dominated this space: Apache Tomcat, Eclipse Jetty, and JBoss Undertow.
As we navigate 2025, the landscape has evolved. The rise of microservices, cloud-native architectures, and the relentless pursuit of performance have shifted the goalposts. Yesterday's default choice might not be the best fit for today's demanding applications. This guide provides an ultimate, up-to-date comparison to help you decide which of these titans is the right choice for your next project.
What Exactly is a Servlet Container?
Before we dive deep, let's clarify our terms. A servlet container is a component of a web server that interacts with Java servlets. In essence, it's the runtime environment for your Java web application. It manages the lifecycle of servlets, maps URLs to specific servlets, and handles the HTTP request and response cycle. While all three contenders are excellent servlet containers, they are also full-featured web servers capable of handling static content, WebSockets, and more.
Deep Dive: Apache Tomcat 10
Apache Tomcat is the undisputed veteran and, for a long time, the de facto standard for Java web applications. It’s the reference implementation for the Java Servlet and Jakarta Server Pages (JSP) specifications. If you've worked with Java web apps, you've almost certainly encountered Tomcat.
Architecture and Philosophy
Historically, Tomcat was known for its thread-per-request model. However, modern Tomcat (versions 8.5+) has evolved significantly, offering highly performant non-blocking I/O (NIO) connectors. Its philosophy is rooted in stability, compliance, and community. It aims to be a robust, specification-compliant server that a massive global community can rely on.
Strengths
- Maturity and Stability: Decades of development mean Tomcat is incredibly stable and battle-tested in countless enterprise environments.
- Vast Community and Documentation: If you have a problem with Tomcat, it's almost certain someone else has already solved it. The wealth of documentation, forums, and tutorials is unparalleled.
- Rich Ecosystem: A vast number of tools, IDEs, and hosting providers have built-in support for Tomcat, making deployment and management straightforward.
- Specification Compliance: As the reference implementation, it offers excellent compliance with Jakarta EE specifications like Servlet, JSP, and EL.
Weaknesses
- Heavier Footprint: Compared to its rivals, Tomcat can have a slightly larger memory footprint and slower startup time, though this gap has narrowed.
- Configuration Complexity: Configuration, particularly for advanced features, often involves editing verbose XML files (like
server.xml
), which can feel dated compared to modern programmatic configuration.
Best For in 2025
Tomcat remains an excellent choice for large-scale, traditional monolithic enterprise applications where long-term stability, predictability, and extensive community support are the highest priorities.
Deep Dive: Eclipse Jetty 12
Eclipse Jetty has always been the nimble, lightweight alternative to Tomcat. It’s designed from the ground up to be embeddable, making it a favorite for developers who need to bundle a server directly within their application.
Architecture and Philosophy
Jetty's core philosophy is modularity and embeddability. It features a fully asynchronous, event-driven architecture. It's not a monolithic server; it's a collection of Plain Old Java Objects (POJOs) that can be easily instantiated and wired together. This makes it incredibly flexible and gives it a very low memory footprint.
Strengths
- Lightweight and Low Memory Usage: Jetty is famous for its small memory footprint and fast startup times, making it ideal for microservices and resource-constrained environments.
- Highly Embeddable: Its component-based architecture makes it trivial to embed within another Java application, which is why it's used in countless tools and frameworks.
- Flexibility: The modular design allows you to include only the components you need, keeping the server lean.
- Asynchronous by Design: Its async-first approach makes it highly efficient at handling a large number of concurrent connections.
Weaknesses
- Smaller Community: While active, its community is smaller than Tomcat's. Finding answers to obscure problems can sometimes be more challenging.
- Perceived Complexity: For those used to Tomcat's file-based configuration, Jetty's programmatic setup can initially seem more complex, although many find it more powerful.
Best For in 2025
Jetty shines in the world of microservices, cloud-native applications, and any scenario where an embeddable server is required. Its low resource consumption makes it a cost-effective choice for high-density deployments.
Deep Dive: JBoss Undertow 2.3
Undertow is the modern powerhouse from the JBoss/Red Hat family, designed for extreme performance and flexibility. It is the default web server for WildFly and has gained massive popularity as the default embedded server in Spring Boot 2 and later.
Architecture and Philosophy
Undertow’s philosophy is performance and flexibility through modern architecture. It is built on non-blocking I/O (NIO) from the ground up and features an innovative, chain-based handler architecture. Instead of a rigid container, you compose functionality by linking together small, single-purpose handlers. This allows for fine-grained control and high performance.
Strengths
- Exceptional Performance: In many benchmarks, Undertow leads the pack in terms of raw throughput and low latency, especially for non-blocking workloads.
- Extremely Lightweight: The core server is incredibly small (the JAR is ~1MB), and it has a very low memory footprint, rivaling and sometimes beating Jetty.
- Flexible Architecture: The handler chain mechanism allows it to support both Servlet applications and modern non-blocking handlers in the same deployment seamlessly.
- Excellent WebSocket Support: Its modern architecture provides first-class, high-performance WebSocket support.
Weaknesses
- Newer and Smaller Community: As the youngest of the three, its community and third-party documentation are less extensive than Tomcat's or even Jetty's.
- Less Standalone Adoption: While dominant as an embedded server (thanks to Spring Boot), it has less market share in standalone deployments compared to Tomcat.
Best For in 2025
Undertow is the go-to choice for high-performance microservices and demanding web applications. Its position as the Spring Boot default makes it the path of least resistance for millions of developers who want top-tier performance out of the box.
Head-to-Head: Tomcat vs. Jetty vs. Undertow
Feature | Apache Tomcat | Eclipse Jetty | JBoss Undertow |
---|---|---|---|
Primary Philosophy | Stability, Compliance, Community | Embeddability, Modularity, Low Footprint | Performance, Flexibility, Modern Architecture |
Architecture | Thread-per-request (classic), mature NIO (modern) | Fully Asynchronous, Event-driven | Non-blocking I/O, Composable Handlers |
Performance | Very good, significantly improved with NIO | Excellent, especially with high concurrency | Exceptional, often leads in throughput benchmarks |
Memory Footprint | Moderate to High | Very Low | Extremely Low |
Embeddability | Possible, but less elegant | Excellent, designed for it | Excellent, designed for it |
Configuration | Primarily XML-based (server.xml ) | Primarily programmatic (Java API) or XML | Programmatic or via framework (e.g., Spring) |
Community | Massive, the largest of the three | Active and robust | Growing, strong ties to Spring/WildFly |
Spring Boot Default | No (but easily configured) | No (was default in v1.x) | Yes (default in v2.x and v3.x) |
Performance Benchmarks in 2025: A Realistic Look
It's crucial to state that benchmarks are context-dependent. Performance depends heavily on the workload, hardware, JVM version (like Java 21+), and configuration. However, general trends hold true in 2025:
- Undertow consistently shows the highest raw throughput in simple "Hello, World!" and lightweight JSON processing benchmarks. Its non-blocking architecture gives it a clear edge here.
- Jetty is extremely competitive, often right behind Undertow. Its strength lies in handling a very high number of concurrent, long-lived connections (like WebSockets) with minimal resource usage.
- Tomcat, with its modern NIO connector, is no slouch. While it may lag slightly in raw throughput tests, its performance is more than sufficient for the vast majority of enterprise applications, and its stability under heavy, complex loads is legendary.
For most microservices, the performance difference between Undertow and Jetty will be negligible in the real world. The choice often comes down to other factors like familiarity and ecosystem.
Which Server Should You Choose?
Here’s a simple decision guide for your 2025 project:
- Choose Tomcat if:
- You are building a large, monolithic enterprise application.
- Stability over decades is more important than a few milliseconds of latency.
- You rely on a vast ecosystem and need guaranteed community support for any issue.
- You are working in a conservative corporate environment where Tomcat is the established standard.
- Choose Jetty if:
- You need to embed a web server directly into your application or tool.
- You are developing microservices in a resource-constrained environment (e.g., small cloud instances, IoT).
- You value a modular design where you can build a server with only the features you need.
- You need to handle a massive number of simultaneous connections efficiently.
- Choose Undertow if:
- Raw performance and low latency are your absolute top priorities.
- You are building high-throughput microservices, especially with Spring Boot (it's the default!).
- You want a modern, flexible architecture that handles WebSockets and HTTP/2 exceptionally well.
- You are comfortable with a newer ecosystem and primarily rely on framework-level configuration.
Final Verdict
The great server debate of Tomcat vs. Jetty vs. Undertow doesn't have a single winner. Instead, we have three excellent, mature solutions tailored for different needs. In 2025, the trend is clear: for modern, performance-critical microservices, Undertow is often the default choice, driven by its speed and integration with Spring Boot. For ultimate flexibility and embeddability, Jetty remains a powerful and relevant contender. And for rock-solid, traditional enterprise deployments, Tomcat continues to be a trusted and reliable workhorse.
The best choice is the one that aligns with your project's architecture, performance requirements, and your team's expertise. Analyze your needs, consider the trade-offs, and choose wisely.