GP - Fotolia

Stateful applications spark container management debate

Stateful applications and container management don't mix, say some IT pros. But others say enterprises need to bring stateful apps into new IT architectures.

Stateful applications are a fact of life for many enterprise shops pursuing containerization, but some argue they should go the way of the dodo.

For most applications, state has to live somewhere. In stateful applications, that somewhere could be the local host, where configuration files and other information are needed to successfully start a stateful application. As for stateful apps on containers, these files must be pulled into the container on startup, and persist somewhere else when containers stop and start. Stateful applications include much of the software used by enterprises, such as Elasticsearch, WebLogic and databases such as MySQL or PostgreSQL.

Stateless applications, meanwhile, place no application state in the container. Microservices or APIs are often employed in greenfield startup environments, because stateless apps allow for containers to be spun up and down by the thousands. Practitioners in these environments say stateless applications are the way of the future, and stateful applications are a legacy technology that can't hang in a rapidly containerizing world.

Legacy technology vs. the real world

Stateless apps are the future, according to some IT practitioners. To others, however, that statement flies in the face of practical reality.

"There was never a need for us to do a stateful app," said Venkat Thiruvengadam, principal engineer for Zenefits, an HR management software-as-a-service company in San Francisco. "It's the legacy way of doing things."

Containers were not made to store persistent data in the first place, added Zubin Irani, CEO of cPrime Inc., an Agile software development consulting firm in San Francisco.

"You'll end up with performance or usability penalties," he said. "Having persistent data in containers also breaks containers' portability on hardware."

Typically, stateful applications rely on files on the host, according to Thiruvengadam, and are common in enterprise private cloud scenarios where remote storage of state information in repositories such as Simple Storage Service is not in use.

That point of view is typical of a startup that built its IT architecture from scratch, countered Chris Riley, a founding partner at HKM Consulting LLC, in Rochester, Mass. Enterprises running in Amazon Web Services have the option of storing configuration files in Amazon's Elastic File System as external storage for stateful applications, he added.

"In the real world, there are still a lot of applications that use file systems for config files, and if you're not building apps yourself and you're leveraging those systems, you have to be aware of host volumes," Riley said.

Some enterprises see stateless apps as the way forward, but some stateful apps should be pulled into containers today.

Stateless apps can scale more gracefully in containers, which are a perfect fit for microservices, said Daniel MacDonald, architect and principal technical lead for a New York agency that's working to adopt Agile software development techniques. But, at the same time, his organization runs MongoDB in a container.

"The container itself is just application code, which is stateless, but we tie it to a host volume, which is stateful," MacDonald said. "The only issue we have with that is the limitation of having that data flow from that one host to a different host, because a container can easily move back and forth."

For this, there are products such as ClusterHQ's Flocker, which can replicate volumes between hosts -- something MacDonald said was definitely needed.

Kubernetes and Mesos battle for stateful application territory

Google's Kubernetes 1.3, released in July, adds support for stateful applications in a product called Pet Sets, which allows for hosts to be named and persist beyond container restarts, as well as a FlexVolume addition that provides persistent volumes for containers' state data. The Kubernetes product page warns that Pet Sets are still in alpha release. 

Mesos, meanwhile, has always had a two-level scheduler for containerized apps to be stateful or stateless, and supports both local and external volumes in beta as of the 1.0 release of Mesosphere's DC/OS.

While general philosophy points toward a future of stateless apps, the reality is the enterprise audience Kubernetes and Mesos are trying to reach runs stateful apps today, and there are advantages to containerizing those apps, according to MacDonald.

"If the container gets corrupted or there's a bug in the configuration code, I always have a fresh point to start over" by restarting the container and reloading configuration data, MacDonald said.

Many apps are stateful, and it's not easy to switch from stateful to stateless, according to cPrime's Irani.

"That's why we are seeing more features and support being added for stateful apps" in platforms such as Kubernetes and Mesos, Irani said. "It's part of the natural evolution of container technology, and if the new features can better support stateful apps, then we should see an increase in container technology being deployed."

Beth Pariseau is senior news writer for TechTarget's Data Center and Virtualization Media Group. Write to her at [email protected] or follow @PariseauTT on Twitter.

Next Steps

IT pros talk real-world Kubernetes

Manage container collections with a Kubernetes cluster

Guide to Docker data storage and containers

Dig Deeper on Managing Virtual Containers