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개 답변
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
전문가
Kallu
답변함 2달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠