Performance Tuning Guide for Undertow Web Server
This guide explains how to boost Undertow’s performance—outpacing Tomcat—by tuning I/O and worker thread counts, buffer sizes, timeouts, disabling unused features, using programmatic customizers, and enabling HTTP/2, with example application.yml settings for optimal speed and memory usage.
Undertow is an open‑source high‑performance Java web server from Red Hat, offering both BIO and NIO mechanisms.
Why not tune Tomcat? While Tomcat can be tuned, Undertow generally outperforms it in speed and memory, making a direct switch preferable.
How to optimize Undertow
Thread pool configuration
Adjust the I/O and worker thread counts in application.yml:
server.undertow.io-threads=8 server.undertow.worker-threads=128Buffer and memory settings
Typical values:
server.undertow.buffer-size=1024 server.undertow.direct-buffers=true server.undertow.buffers-per-region=...Connection and request timeouts
server.undertow.max-http-post-size=0 server.undertow.no-request-timeout=1800sDisable unnecessary features
server.undertow.session-cookie-config=none server.undertow.accesslog.enabled=falseProgrammatic configuration can be done by implementing
WebServerFactoryCustomizer<UndertowServletWebServerFactory>.
Enable HTTP/2 via server.undertow.enabled-http2=true.
Example application.yml snippet:
# IO threads
server.undertow.io-threads=16 # Worker threads
server.undertow.worker-threads=128 # Buffer size
server.undertow.buffer-size=512 # Direct buffers
server.undertow.direct-buffers=true # HTTP/2
server.undertow.enabled-http2=trueSigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Tech Enthusiast
Sharing computer programming language knowledge, focusing on Java fundamentals, data structures, related tools, Spring Cloud, IntelliJ IDEA... Book giveaways, red‑packet rewards and other perks await!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
