Search code examples
amazon-web-servicesnginxload-balancingamazon-elbaws-application-load-balancer

AWS application load balancer on unknown dynamic url paths


Is it possible to do url path load balancing on an AWS application load balancer when the paths are generated dynamically? e.g

example.com/abc12345 example.com/abc54321

Please note there is no structure to how the urls are formed

I've got a scenario where "rooms" will be generated dynamically and I want to be able to load balance them. The names of the rooms won't be known upfront and the other issue is that an external service will ping them (hence why I need to load balance on the url rather than a cookie/session).

Does anyone know if this is able to be accomplished, or is there a better way to achieve this. I'm not familiar enough with load balancing methods. My initial thoughts would be very simple in that I hash the PATH and then retrieve an integer value from it (Via modulus or equivalent) and load balance based on that.

Any advice greatly appreciated.

I'm specifically looking at AWS in this instance due to the location of other resources, but if this could be achieved via something like NGINX and spinning up my own Load Balancer I'd be all ears.


Solution

  • You can deploy a Cloudfront distribution in front of your application. with CF, you can route different path by prefix to different load balancers. (/abc* to LB1 and /xyz* to LB2) You can even route some paths to non–AWS endpoints or S3 buckets.

    Doc: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#DownloadDistValuesPathPattern

    With Cloudfront you also access to other features such as caching specific paths and it will also accelerate your application globally comparing to having Load Balancers in one region.