DEV Community

Cover image for AWS ALB routing based on HTTP method
Kamal Mustafa
Kamal Mustafa

Posted on

AWS ALB routing based on HTTP method

tldr;- It's not possible at this moment.

The new AWS ALB has more flexible way to route incoming requests compared to ELB classic but still fell short. It only support path or host based routing. So you can route requests to /customers/logs/ and /customers/orders/ to different target group, like different cluster of ec2 instances.

But it's not possible to route based on http method, like POST /customers/orders/ and GET /customers/orders/ to different target. One practical use case is when GET /customers/orders/ will be resources intensive and you want to segregate the requests to avoid impact on other parts of your services.

Today, a friend also shared about load balancer from the guy at Gojek (ride hailing services in Indonesia) called Weaver. It seem to support method based routing:-

  "id": "gojek_hello",
  "criterion" : "Method(`POST`) && Path(`/gojek/hello-service`)",
  "endpoint" : {
    "shard_expr": ".serviceType",
    "matcher": "body",
    "shard_func": "lookup",
    "shard_config": {
      "999": {
        "backend_name": "hello_backend",
Enter fullscreen mode Exit fullscreen mode

The criterion expressed based on Vulcand Routing, which is another load balancer from MailGun. The vulcand documentation say:-

package route provides http package-compatible routing library. It can route http requests by hostname, method, path and headers.

And that's all for my own notes.

Image credit to

Top comments (1)

k4ml profile image
Kamal Mustafa

Advance requests routing finally come in ALB -