Skip to main content

How to keep state alive between deployments [Resolved]

In our history, when we did a new release (deployment) any user who was "logged in" was logged out and that was obviously not ideal. Then I switched platform from a custom stack to a cloud provider and a "managed" platform which seems to have solved the problem. AFAIK a user can stay logged in during a deployment and the state is kept alive. How is it usually solved in practice behind the scenes?

The details are that we first used on-prem combination of tomcat connected to mysql with apache httpd, then replaced everything with Google Appengine.


Question Credit: Niklas Rosencrantz
Question Reference
Asked September 17, 2019
Posted Under: Programming
26 views
1 Answers

The trick is to not keep any session state within the stuff you redeploy. Instead:

  • keep state in a separate database that persists beyond a deployment, or
  • keep state purely client-side.

Where a web framework keeps state in-process or in tempfiles, a redeploy necessarily destroys that state. A subtle variant of this is if tokens or keys are generated during startup of the deployed instance, rather than being provided to the instance from some external storage.

I'd strongly recommend looking at the 12 Factor App which discusses how to create web-appish or cloudy software. It recommends that processes should be stateless and disposable, which implies that state must be external of the deployed process.


credit: amon
Answered September 17, 2019
Your Answer