Distributed HTTP Sessions in Java on Heroku with Memcache
Last updated 09 September 2015
Table of Contents
Storing any type of session state on the server side of your application is a barrier to scalability. The best way to keep state is to directly use a database or some other data store that horizontally scaled instances can share. Modern frameworks such as the Play Framework encode this best practice into their APIs. Any (small) amount of session state such as a user id or data lookup keys are stored client side in a cookie. Any other data is explicitly stored and retrieved from a backend store.
Although it is best to avoid the practice some Java frameworks rely on using
javax.servlet.http.HttpSession to store their state information. In these cases you can use a session mananger that is backed by a shared data store such as Memcache.
If you have questions about Java on Heroku, consider discussing them in the Java on Heroku forums.
Using Memcache backed sessions
Memcache backed sessions can be used on Heroku with Tomcat and the memcached-session-manager. To learn how see the Dev Center articles on: