- Newest
- Most votes
- Most comments
ALB sticky sessions cannot route based on path segments or document IDs. ALB stickiness uses cookies (AWSALB or AWSALBAPP) to bind a client to a target, not to route specific URL paths to specific backends. This means different clients requesting the same document_id will be routed to different pods, which does not meet your requirement. ALB target group routing algorithms (round robin, least outstanding requests, weighted random) do not support key-based or hash-based routing on request attributes. what you can do is adding a Consistent Hashing Layer. NGINX Ingress supports the nginx.ingress.kubernetes.io/upstream-hash-by annotation to hash requests based on request attributes. This ensures requests with the same document_id consistently route to the same pod. NGINX uses a hash ring algorithm, so scaling pods only remaps a fraction of keys rather than redistributing all traffic. Alternative: Istio/Envoy If using a service mesh, configure Istio's DestinationRule with consistentHash on a request header or URI parameter. Istio supports ring hash and Maglev algorithms. some design consideration: If your requirement is driven by per-document state stored in pods, consider externalizing state to ElastiCache (Redis) or DynamoDB instead. This eliminates the need for affinity and makes your application resilient to pod restarts and scaling events.
answered 3 months ago
Relevant content
asked 3 years ago
