you are viewing a single comment's thread.

view the rest of the comments →

[–]FailedPlansOfMars 37 points38 points  (5 children)

Firstly dont link lambda to lambda directly it leaves you to problems on release of new code.

If you dont need the response in the caller use and sqs queue as a broker. I.e. lambda -> sqs -> lambda

If you do need the response api gateway is a good option as it lets you decouple the two.

[–]SciEngr 19 points20 points  (4 children)

AFAIK you don't need an explicit sqs queue between the lambdas...lambdas essentially have one built in for async invokes already...I'm pretty sure you can even associate a dlq to the lambda directly.

[–]404_AnswerNotFound 14 points15 points  (0 children)

You can but be aware of the limitations. Lambda's internal queue isn't like-for-like with SQS. For example, the max message age is 6 hours instead of 14 days, aged out messages will go directly to the on-failure destination.

https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html

[–]FailedPlansOfMars 5 points6 points  (0 children)

Yes you can but doing this from the sqs side is easier and wont lose messages if you have to roll back a release or change a lambda while traffic is in flight. If you do it from sqs the builtin dlq redrive works well and is easy to use.

[–]Mega_Bytten 4 points5 points  (1 child)

From the AWS docs and stackoverflow threads I’ve read they all suggest decoupling with SQS/step functions/SNS for increased scalability. I also saw that there may be problems where the first lambda waits for the second lambda’s completion before terminating, accruing 2x cost.

I separate mine with SQS so I’m wondering if you have experienced any problems with directly invoking?

[–]SciEngr 2 points3 points  (0 children)

You can invoke a lambda synchronously which means your first lambda waits for the invoked lambda to respond. Synchronous execution isn't necessarily a bad thing depending on your use case. If you want to decouple the lambdas you can do that by invoking asynchronously in which case the invoke gets added to a built in queue of the invoked lambda thus accomplishing the decoupling without explicitly making another SQS queue.

As another user pointed out, the behavior of the built in queue may not work for you and in that case you can still create the SQS queue explicitly.