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 年前檢視次數 654 次
1 個回答
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
專家
已回答 1 年前
  • 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

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南