Embedded Server Configuration (Tomcat, Jetty, Undertow)
Fast recall
Quick revision
Core answer
spring-boot-starter-tomcat and adding the desired alternative — a single dependency swap, no code changes. Tomcat is the most battle-tested; Undertow offers the lowest memory footprint and highest servlet throughput; Jetty is a solid middle ground with strong WebSocket and SSE support. All three are configured through the server.* property namespace. For reactive WebFlux apps the default is Netty — an event-loop server that suits non-blocking I/O.Whether the candidate knows the trade-offs between the three servers and can justify a server choice for a given workload
Thinking that switching embedded servers requires code changes — it is a single dependency swap because Spring Boot abstracts the server behind `WebServer`/`ServletWebServerFactory` interfaces
Mention that for reactive WebFlux applications Netty is the default (not Tomcat), and explain how to customise the server via `WebServerFactoryCustomizer` for connection pooling, thread counts, and SSL configuration
Interview-ready guide
Interview answer
Spring Boot embeds the web server inside the JAR — Tomcat by default, with Jetty, Undertow, and Netty as alternatives. Choosing and configuring the right server affects throughput, memory usage, and the concurrency model.
Switching servers
- Exclude
spring-boot-starter-tomcatfromspring-boot-starter-weband addspring-boot-starter-jettyorspring-boot-starter-undertow - Spring Boot auto-detects the server implementation on the classpath — no code changes required
- WebFlux applications use Netty by default; Netty is non-blocking and handles thousands of concurrent connections on a small thread pool; Tomcat uses one thread per request
Key Tomcat settings
server.tomcat.threads.max=200(default) — the maximum number of simultaneous requests; increase for high-concurrency workloads, but each thread consumes memoryserver.tomcat.accept-count— the queue depth when all threads are busy; requests beyond this are rejected
Common configuration
server.port=8080,server.compression.enabled=true,server.ssl.key-store— configured viaapplication.propertieswithout touching codeserver.shutdown=graceful— allows in-flight requests to complete before the JVM exits
Programmatic customization
WebServerFactoryCustomizerexposes server-specific knobs that have no property equivalent- Guard with
@ConditionalOnClassso the bean activates only when the matching server is on the classpath
The decision between Tomcat and Netty is architectural: blocking I/O with Tomcat suits traditional request-response Spring MVC; non-blocking event-loop Netty suits reactive WebFlux. Do not mix — using a blocking call inside a Netty event loop blocks the loop and kills throughput.
Embedded Server Configuration (Tomcat, Jetty, Undertow)
Direct Answer
Spring Boot defaults to embedded Tomcat but supports Jetty and Undertow by excluding spring-boot-starter-tomcat and adding the desired alternative — a single dependency swap, no code changes. Tomcat is the most battle-tested; Undertow offers the lowest memory footprint and highest servlet throughput; Jetty is a solid middle ground with strong WebSocket and SSE support. All three are configured through the server.* property namespace. For reactive WebFlux apps the default is Netty — an event-loop server that suits non-blocking I/O.
Common Mistakes & Pitfalls
Thinking that switching embedded servers requires code changes — it is a single dependency swap because Spring Boot abstracts the server behind WebServer/ServletWebServerFactory interfaces
Check your understanding
Answer these without looking back at the article.
- How do you configure the maximum number of threads for embedded Tomcat in Spring Boot?
- How would you add SSL/TLS to an embedded server without modifying application code?
- What is the default embedded server for a Spring Boot WebFlux application and why?
- How does graceful shutdown interact with in-flight requests on Tomcat vs Netty?
Related interview prep categories
1Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.