How make sticky sessions path based for ALB, when using it in front of EKS

0

I am using an EKS cluster and direcly in front of it an ALB.

Now, there are many requests of the form https://my-domain.com/some-service/<document_id>, where document_id is varying.

Now, I would like to route traffic in EKS for document_id1 to pod1, for document_id2 to pod2, for document_id3 perhaps again to pod1 etc. In any case, I would like to send traffic for each fixed document_id to just one or at most a few pods in the Kubernetes cluster.

Is that or something similar possible by using sticky sessions for ALB? Or is there an alternative to it?

1 Answer
0

I'm afraid this isn't possible with ALB. Sticky session is for binding a client session to specific target, ie. all requests from given client are routed to the same target. ALB. You can configure routing algorithm that selects which target (within the group) the request is routed to, but there is no option to base routing on URL path.

load_balancing.algorithm.type

The load balancing algorithm determines how the load balancer selects targets when routing requests. The value is round_robin, least_outstanding_requests, or weighted_random. The default is round_robin. See https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html#target-group-routing-configuration

I think what you are trying to do is called "sharding". Here is a sample how you could do this with help of Cloudfront Functions that would calculate the shard id based on URL and add that into URL. Then you could configure ALB target groups based on shard id and get request for even and odd documents routed to different tasks like you had in your example.

https://github.com/aws-samples/shuffle-sharding-demo-app

profile picture
EXPERT
Kallu
answered 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions