4

I am planing on using AWS SQS to receive messages from server and then instantly have Kubernetes Load Balancer consume them and pass each message to one of the pods.

My biggest concern is in which way can Load Balancer be triggered by AWS SQS.

Is this possible to do?

If yes in what way?

  • 1
    You can't do this directly. You could do: SQS->Lambda->LB. – Marcin Feb 13 '21 at 11:03
  • Yeah I was afraid I might have to do that. – Tomislav Stampfel Feb 13 '21 at 13:21
  • Which solution did you end up implementing? Right now, I'm forwarding requests from SQS to my ALB through Lambda but I'm running into issues with error tracking. See [here](https://stackoverflow.com/questions/66766442/registering-load-balancer-errors-in-lambda-metrics). – Evan Lalo Mar 23 '21 at 16:43

1 Answers1

4

To expand on @Marcin's comment:

There is no integration between the Elastic Load Balancer implementations and SQS in any direction. Part of the reason is, that they both implement a pattern, which requires a trigger from the outside for them to do anything.

To consume a message from SQS, the consumer needs to actively poll SQS for work using the ReceiveMessage API call.

For the load balancer to serve traffic there needs to be a request from the outside it can respond to.

To get an integration between two passive/reactive services you need an active component inbetween. You could build for example a fleet of containers or a Lambda function. Lambda can be triggered via SQS (under the hood Lambda will poll SQS) and could subsequently send a request to your ALB or whichever load balancer you choose.

Maurice
  • 11,482
  • 2
  • 25
  • 45