Skip to content
Latchkey

What Is Statelessness? Services That Keep No Memory

A stateless service keeps no per-client state between requests; everything it needs comes in with the request or from external storage.

Statelessness is the property that makes a service instance disposable. If a service remembers nothing between requests, any instance can serve any request, and you can add, remove, or restart instances freely. It is the quiet enabler behind horizontal scaling, rolling deploys, and the ephemeral environments CI depends on.

What stateless means

Each request carries (or can fetch) everything needed to handle it. The service does not rely on data held in local memory from a previous request. Session data, if any, lives in a shared store, not in the instance.

Why it matters

  • Any instance can serve any request, enabling load balancing.
  • Instances can be added or killed without losing data.
  • Restarts and crashes lose nothing important.
  • It is the precondition for clean horizontal scaling.

Where the state goes

Statelessness does not delete state; it relocates it. Sessions move to a cache like Redis, data to a database, files to object storage. The service becomes a pure transformer, and the stateful parts are concentrated where they can be managed deliberately.

A gift to CI/CD

Stateless services are trivially easy to deploy: spin up the new version, shift traffic, kill the old, no data migration of in-memory state, no draining of sticky sessions. This is what makes rolling and blue-green deploys safe and routine.

Easier to test, too

A stateless handler is a function of its input, which makes it straightforward to unit-test deterministically. There is no hidden in-memory state to set up or reset between tests, so test isolation comes more naturally.

Stateless by design on runners

CI runners themselves are best kept stateless: each job gets a clean environment and leaves nothing behind. Latchkey runners are ephemeral and stateless by design, so one job cannot poison the next.

Key takeaways

  • A stateless service holds no per-client memory between requests.
  • It makes instances interchangeable, enabling scaling and zero-fuss deploys.
  • State is relocated to caches, databases, and object storage, not eliminated.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →