Sticky sessions ensure that repeat client requests are routed to the same backend pod, which is essential for maintaining user session state. When combined with drain support, you can implement graceful pod termination during deployments or scaling events, allowing existing sessions to complete while preventing new traffic from being routed to pods that are shutting down.
Kong’s sticky sessions feature uses browser-managed cookies to route repeat requests from the same client to the same backend target. When a client first connects, Kong sets a cookie in the response. On subsequent requests, if the cookie is present and valid, Kong routes the client to the same target.
Sticky sessions are useful for:
- Session persistence across multiple requests
- Applications that store session state locally
- Improving cache hit rates