How does Tomcat 9.0.80+ handle graceful shutdown when using the NIO connector?
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
gracefulStopAwaitMillis="15000"
bindOnInit="false"
protocol="org.apache.coyote.http11.Http11NioProtocol" />
I'm already using HAproxy with retries, redispatch and health checks. I have also configured Tomcat to use graceful shutdown and late binding (as per recommendation) to let any reverse proxy/load balancer redispatch to another backend. But I'm unsure if it actually waits for in-process requests to finish processing before exiting. My testing indicates so, but I occasionally get a HTTP 502 from the public facing ALB (TLS, WAF) that sits in-front of HAproxy(advanced routing, API gateway) and then a whole bunch of Tomcat servers that get rolling restarts.
Conclusion
It does not guarantee that all requests will be processed!
As far as I can tell this is what happens: