DEV Community

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

Posted on

3 3

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",
        "backend":"http://hello.golabs.io"
      }
    }
  }
}
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 https://www.flickr.com/photos/small_realm/14699606019.

Sentry image

Make it make sense

Only the context you need to fix your broken code with Sentry.

Start debugging →

Top comments (1)

Collapse
 
k4ml profile image
Kamal Mustafa

Advance requests routing finally come in ALB - aws.amazon.com/blogs/aws/new-advan....

Image of Stellar post

🚀 Stellar Dev Diaries Series: Episode 1 is LIVE!

Ever wondered what it takes to build a web3 startup from scratch? In the Stellar Dev Diaries series, we follow the journey of a team of developers building on the Stellar Network as they go from hackathon win to getting funded and launching on mainnet.

Read more

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay