Session affinity
Session affinity is a traffic-routing policy that directs successive requests from a client or session to the same backend instance.
Kubernetes in Action, Second Edition
Cookie-based session affinity is a traffic-routing policy that uses an HTTP cookie to keep a client associated with the same backend instance.
- How it is used
- Routes repeated HTTP requests from one client to the same backend through an Ingress.
- How deep it goes
- Explains layer boundaries, annotations, cookie naming, manifest configuration, and curl verification without developing controller internals.
- Examples
- Uses Nginx annotations, a named SESSION_COOKIE, Set-Cookie output, and repeated curl requests.
- What you can do after
- Operate/configure cookie affinity by applying an Nginx Ingress manifest and replaying the returned Cookie header.
Read how Kubernetes in Action, Second Edition explains session affinity →
Learn Docker in a Month of Lunches, Second Edition
A sticky session is session affinity that routes repeated requests from a client to the same service instance when possible.
- How it is used
- Routes a client back to one container when an application depends on instance-local session state.
- How deep it goes
- Explains the cookie-based routing mechanism and demonstrates it with scaled containers, but does not detail service-label syntax.
- Examples
- Demonstrates a scaled who-am-I application, repeated curl requests, and a c.txt cookie jar.
- What you can do after
- Configure and verify sticky sessions in Traefik while comparing cookie-persisted routing with ordinary load balancing.
Read how Learn Docker in a Month of Lunches, Second Edition explains session affinity →
Related concepts
- canary deploymentused by · A canary deployment is a release strategy that exposes a change to a limited portion of users, traffic, or infrastructure before expanding it more broadly.
- serviceconfigures · A Kubernetes Service is an API resource that provides stable network access and service discovery for a changing set of Pods or other specified destinations.
- statefulnessuses · Statefulness is the property of a system or operation whose behavior or results depend on information retained or changed across interactions or executions.
- annotationconfigured by · A Kubernetes annotation is key-value metadata attached to an object for storing non-identifying descriptive, configuration, or operational information.
- Traefikimplements · Traefik is an open-source dynamic reverse proxy and load balancer that configures routing using service discovery and runtime metadata.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

