Spring Boot provides embedded servers that can run web applications in a JAR file. A few of the available embedded servers for use are Tomcat, Undertow, Webflux, and Jetty. It is advisable to have Undertow as the embedded server. Undertow provides more throughput and consumes less memory compared to Tomcat and Jetty. The following comparisons may provide some insight:
- Throughput comparison:
Server |
Samples |
Error % |
Throughput |
Tomcat |
3000 |
0 |
293.86 |
Jetty |
3000 |
0 |
291.52 |
Undertow |
3000 |
0 |
295.68 |
- Heap memory comparison:
Server |
Heap size |
Used |
Max |
Tomcat |
665.5 MB |
118.50 MB |
2 GB |
Jetty |
599.5 MB |
297 MB |
2 GB |
Undertow |
602 MB |
109 MB |
2 GB |
- Threads comparison:
Server |
Live |
Started |
Tomcat |
17 |
22 |
Jetty |
19 |
22 |
Undertow |
17 |
20 |
From the preceding comparisons, Undertow looks like the obvious choice for an embedded server in Spring Boot applications.