How to use Application Load Balancer to route traffic to different backend services

0

I have two boxes let's say box A and Box B. Both has seperate service applications with its own dbs. Both boxes should do calls to third-party legacy websocket /rest endpoints which cannot be changed in anyway. This third party endpoint is called through ALB and ALB IP is whitelisted on their end

When a box A make (rest/websocket) request to 3rd party endpoint relative response should arrive in Box A

same applies to Box B how to achieve this? Would Application Load Balancer know how to deliver each response to it's correct requester? Note application in A and B are background services not browsers.

1 Answer
1

Based on your question, you want an AWS Application Load Balancer (ALB) to route incoming traffic from a third-party source to either box A or box B, depending on which box made the initial request to the third-party service.

this type of request-reply correlation is not inherently supported by ALB. The main function of an ALB is to distribute incoming application traffic across multiple targets, such as EC2 instances, in multiple Availability Zones. It doesn't inherently manage state or handle the correlation of requests and responses in the way you're describing.

For REST API calls, each request-response cycle is typically independent and stateless. Therefore, if box A and box B are making separate requests to a third-party service, each will receive its own response directly, without the involvement of ALB.

For WebSocket connections, it's a little more complex because these are stateful connections. If box A opens a WebSocket connection to a third-party service through the ALB, and then box B does the same, each box will have its own separate WebSocket connection and will receive responses on that connection.

However, if you are trying to route third-party responses that come independently of any request (i.e., asynchronous responses), the ALB will not be able to direct those responses based on prior requests.

If you need to handle complex routing based on your application's internal logic or based on request-reply correlation, you might consider implementing a service mesh with AWS App Mesh or using AWS Lambda with AWS Step Functions to manage the state and routing logic. These services provide more granular control over request routing and state management.

It's also important to note that, in some scenarios, you might need to modify the design of your application services or discuss with the third-party service provider to support the routing needs.

profile picture
EXPERT
answered a year ago
  • Thanks for your answer. Can I use APi Gateway instead of appmesh and intergrate with lambda to do complex route decision making? If so could you kindly share any links how I can do this or point me what should I be doing/searching to go about it

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions