Friday, October 14, 2011

25% tip?

I think I grabbed this snapshort from sfgate.com, saying 25% tip is too low or something. Anyway, the problem about this picture is: this picture actually is about a waiter is preparing food for the group dinner of Communist Party in China. 

Wednesday, March 2, 2011

Tomcat 7 hot deploy, rolling upgrade

My client needs their Java web application available 24x7, but you have to restart Tomcat for any Java changes and that bring down the application. Then some users may lose their session and fail to save their data. It can be even worse: user may be in the middle of making payment and then suddenly the user was kicked out, he may have been charged but your system hasn't recorded that.

Fortunately now Tomcat 7 has this revolutionary solution http://tomcat.apache.org/tomcat-7.0-doc/config/context.html.

All you need to do is to
1. keep your old app foo.war untouched
2. name your new version of app to foo##0001.war and upload to webapps folder

The old session will use foo.war, and new user will use foo##0001.war. Here are some details:

  • If no session information is present in the request, use the latest version.
  • If session information is present in the request, check the session manager of each version for a matching session and if one is found, use that version.
  • If session information is present in the request but no matching session can be found, use the latest version.
As Tomcat compare version by comparing string, you have to name your file like foo##0001.war, foo##0002.war, foo##0011.war.
If you name it like foo##11.war and foo##2.war, foo##2.war will be considered newer version than foo##11.war

Followers