liveBook · Manning

Stateless system

As explained in Kubernetes for Developers

A stateless application is an application whose instances do not retain client or operational state between requests or executions.

Suppose traffic suddenly surges and you need more copies of your application. Scaling is easier when any copy can handle the next request. In a stateless design, each replica can serve an incoming request without relying on data stored locally by another replica. section 1.0 section 6.4.1

Stateless does not mean the application uses no data. Keep data that must survive a request or be available to other replicas in an external store. SQL or NoSQL databases can hold structured data, object storage can hold files, and a memory database such as Redis can hold session state. Local ephemeral storage is still useful for temporary processing when its contents need not be shared or available to a later request. section 6.4.1

In Kubernetes, a stateless application can run as a Deployment: its Pod definition identifies the containers to run, and its replica count states how many instances you want. Kubernetes places those Pods in the cluster. Container disk data is ephemeral by default, so do not treat it as durable application state. section 1.2.1 section 6.4.1

Some workloads genuinely need persistent state. Kubernetes can support them with persistent volumes and StatefulSets, but that is a different choice from keeping easily replicated application instances stateless. A platform as a service may deploy stateless frontends simply; check whether it can also accommodate a required stateful backend before relying on that simplicity. section 6.4.1 section 1.2.3

How Kubernetes for Developers covers it

How deep it goes
Defines replica independence, distinguishes temporary from durable storage, and gives deployment guidance without detailing StatefulSet configuration.
Examples
Uses a sudden traffic surge, temporary local processing, and SQL, NoSQL, object, and session stores.
What it assumes
Introduces Pods as grouped containers and explains replicas rather than requiring prior Kubernetes workload vocabulary.
What you can do after
Operate/configure it in Kubernetes by setting Deployment replicas and keeping durable or shared state outside application instances.
How it connects
Connects stateless design to Kubernetes Deployments, Pods, external data stores, persistent volumes, and StatefulSets.

Also explained in

Compare how 14 books explain stateless system →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kubernetes for Developers. The section links point to the parts of the book it draws on.