We have a tomcat cluster with a load balancer (haproxy). As part of our upgrade script we would like to starve a single tomcat in the cluster of 3, wait until all the requests are handled for that particular tomcat. and only then we would like to shut it down and upgrade the web application running on that tomcat.

Our question is:

How can our script indicate if the tomcat is fully starved (all request have been taken cared of)?

Is there an API the tomcat itself exposes? or maybe we can query haproxy for that info?


EDIT: Here is my haproxy configuration file:

stats socket /etc/haproxy/haproxysock level admin

mode http
timeout connect 5s
timeout queue   300s
timeout client  300s
timeout server  300s

frontend http-in
bind *:8080
default_backend NG

backend NG
cookie JSESSIONID prefix
server cookie JSESSIONID_SERVER_1 check maxconn 500
server cookie JSESSIONID_SERVER_2 check maxconn 500
#server cookie JSESSIONID_SERVER_3 check maxconn 500
option httpclose
option forwardfor
balance roundrobin
option redispatch
retries 15

listen admin
bind *:8081
stats enable
stats refresh 1s
  • How is session persistence implemented in your haproxy configuration? You may wish to add the pertinent configuration details to your question. Jun 17 '14 at 11:59
  • Please see my EDIT
    – Urbanleg
    Jun 17 '14 at 12:49

Complete starvation is difficult to assert from the loadbalancer's point of view. There is really no telling wether there is a client still out there who has a JSESSIONID cookie that is prefixed for your NOLB server.

I can see at least two ways to go forward with this

  1. estimate total starvation time based on your session lifetime
    • this is not perfect of course, since TTLs are getting renewed during the starvation phase
  2. define a boundary (like 1 request per minute) to consider the server as starved

If Tomcat does have a way to enumerate valid sessions, that would allow for a safer way (via a servelet or similar).

Note that if you constrain yourself to stopping only fully starved appservers, a tenacious client can keep you from ever restarting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.