The rapid migration to containers has led to some confusion around maintaining state. Containers should support both stateful and stateless models Credit: Thinkstock Most applications are stateful. Stateful is when streaming services remember where you left off in a movie even if you switch devices, or mobile applications store users’ preferences or recently opened files. For application-level cases, it’s the ability to recover from a session interruption, putting the users back to the place they left off, without loss of data. We come from a stateful world. Stateful applications remember things about states, which is durable across sessions. The state data is stored within some nonvolatile mechanism, such as physical storage, including databases. Enter containers, with new challenges and opportunities regarding state retention. In the world of containers, we are taught to be stateless. In container design, including courses I’ve taught, the idea is that a container emerges as an instance, does what it’s programmed to do, and goes away without maintaining state. If indeed it works on data from some external source, it’s handed the data by another process or service, returning the data to another process before being removed from memory. Still, no state maintained. The core issues are that containers, as invented years ago, just could not save state information. There was no notion of persistent storage, so maintaining state was impossible. We were taught early on that containers were for operations that did not require state retention. Some people still argue the need for stateless when building container-based applications, contending that it’s the cleanest approach, and that thinking stateful means thinking in outmoded ways. However, that may not be acceptable to most enterprises developers who are using containers. Traditional applications are not purpose-designed and built for containers. For example, applications refactored for containers are typically stateful and depend on state data. Attempting to make these applications stateless is typically a Herculean effort. It adds cost and risk to the point of “why bother moving them to containers?” Moreover, even scratch-built container applications targeted for containers may find that maintaining state is a fundamental feature that they can’t avoid based on a business need. Indeed, workarounds to make applications stateless that should maintain state are really not going to be the cleanest approach. The case can be made that container-based applications need to support both state models. Good thing Kubernetes and other technologies provide mechanisms to be stateful. In fact, given the fact that many container-based systems will be federated/distributed, stateful is a core requirement of those architectures. What’s my take on this? All applications, including container-based applications, need to provide developers with an option to be both stateful and stateless. It’s just too limiting to say that stateless applications are the only valid approach when most developers know that in the real world that’s not true. Related content analysis Generative AI won’t fix cloud migration You’ve probably heard how generative AI will solve all cloud migration problems. It’s not that simple. Generative AI could actually make it harder and more costly. By David Linthicum Jul 12, 2024 5 mins Generative AI Artificial Intelligence Cloud Computing analysis All the brilliance of AI on minimalist platforms Buy all the processing and storage you can or go with a minimum viable platform? AI developers and designers are dividing into two camps. By David Linthicum Jul 09, 2024 5 mins Generative AI Cloud Architecture Artificial Intelligence analysis The next 10 years for cloud computing Despite AI's explosive growth, the industry still needs to face facts that customers are unhappy about costs and vendor lock-in. By David Linthicum Jul 05, 2024 5 mins Amazon Web Services Google Cloud Platform Microsoft Azure analysis Serverless cloud technology fades away Serverless was a big deal for a hot minute, but now it seems old-fashioned, even though its basic elements, agility and scalability, are still relevant. By David Linthicum Jul 02, 2024 4 mins Serverless Computing Cloud Computing Software Development Resources Videos