A sticky session is session affinity that routes repeated requests from a client to the same service instance when possible.
Session affinity routes repeated requests from one client to the same service instance when possible. It helps older applications that are not stateless, while stateless applications generally benefit from routing requests to any available container. section 20.4
Traefik implements session affinity by:
Setting a cookie that identifies the container for the client. section 20.4
Reading that cookie on later requests and routing them to the same container. section 20.4
Keeping repeated calls together instead of distributing them across scaled containers. section 20.4
How Learn Docker in a Month of Lunches, Second Edition covers it
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 it assumes
Assumes Docker Compose, containers, curl, and basic load-balancing concepts.
What you can do after
Configure and verify sticky sessions in Traefik while comparing cookie-persisted routing with ordinary load balancing.
How it connects
Connects session affinity with load balancing, reverse proxies, stateless components, cookies, and container scaling.
Kubernetes in Action, Second EditionCookie-based session affinity is a traffic-routing policy that uses an HTTP cookie to keep a client associated with the same backend instance.
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.
This explainer was generated by Manning's knowledge graph from the text of Learn Docker in a Month of Lunches, Second Edition. The section links point to the parts of the book it draws on.