Search code examples
routesload-balancingamazon-route53aws-application-load-balancersystem-design

Route traffic based on HTTP headers


I am designing a scalable micro-service architecture using Kubernetes. The current setup looks like this:

Client --> Route53 --> ALB(Ingress) --> Application (Running inside EKS cluster)

This works fairly well with one Application Load Balancer(ALB). Now I want to scale this architecture by creating multiple EKS clusters in the same/different regions. The architecture diagram I am trying to achieve looks like this:

                        ________ ALB 1(Ingress) --> Application (Running inside EKS cluster 1)
                       |
Client --> Route53 ----|
                       |________ ALB 2(Ingress) --> Application (Running inside EKS cluster 1)

There can be n number of such ALBs available. I want to redirect the request from Route53 --> ALB depending on a particular header value. How can I add custom logic to determine the appropriate ALB?

I am free to use some other service instead of Route53 if required.


Solution

  • 2 approaches come to mind-

    1. Using single ALB and sub-domain(say foo.domain.com)- In order to do a URI-based routing, you would need a reverse proxy like Nginx behind your ALB where you could implement URI-based routing. Something like this -

    Any Domain --> ALB --> Nginx (Clustered/Active-Passive) --> Application 1 or Application 2

    1. Using multiple ALBs and sub-domains(say foo.domain.com, bar.domain.com)- Now you can create multiple target groups, 1 corr. to 1 ALB and do a sub-domain based routing. Something like this -

    Domain 1 --> ALB 1 --> Application 1

    Domain 2 --> ALB 2 --> Application 2