liveBook · Manning

Session affinity

Session affinity is a traffic-routing policy that directs successive requests from a client or session to the same backend instance.

How 2 Manning books explain it

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

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.