Showing how externalising the HTTP Servlet session into a database can work.
pushd app
./gradlew docker
popd
docker-compose up
This should build the application, and create a docker environment with 3 instances of the application talking to a single MySQL database, and haproxy as a load-balancer in front of the apps.
http://localhost/ should give you the same session ID each time.
Kill an instance of the tomcat application; the session should continue to work.
- have a client access the site to few times
- only a single session should be created
- Check the logs that a CleanupObject instance has been created
- Sequentially stop and restart each
app_x
instance - client sessions aren't interrupted by this
- wait for a minute or two for the sessions to expire
- you should see valueUnbound events in the logs as CleanupObjects are purged
See zero-downtime-deployment.sh.
- have a few clients access the site to create sessions
- Check the logs that various CleanupObject instances have been created
- stop all of the
app_x
instances to simulate extended downtime of the application / segfaults - wait for 2 minutes (session timeout is 1 minute)
- start one or more of the
app_x
instances - after a minute or so, you should see valueUnbound events in the logs as CleanupObjects are purged
See extended-downtime.sh.
- have a client access the site a few times
- only a single session should be created
- request the image using the client session
- is the session loaded from the DB?
- request the image using no session cookie (replicating a cookie-less domain)
- is the session loaded from the DB?
See image-session.sh.