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.
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.
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?
I’ve personally used: API Gateways, boto3 invocation, and step functions. They all have different applications depending on what you need to do.
In general, asynchronous is better than synchronous since nesting lambda calls just means that you’re spending for one lambda to idle while it waits for another; plus it’s really easy to time out and fail that way.
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.
If you have a lambda, you should not synchronously call another lambda. You end up paying double the cost during the time you’re waiting for a response. It gets worse for each layer of invocation.
Try to design your lambdas in such a way that they can do all the work they need to do and then ship off their results for something else to process.
Don’t make a distributed call stack with lambda…that’s gonna cause you a lot of pain and money.
This article made me think I could set up an API gateway with a POST and GET.
Post - write to db and return an id, then trigger a lamb that writes to SNS to trigger my next Lambda and chain my lambdas like that. Each lambda updates the DB.
Get - checks the DB to see if all my lambdas are done running to return completed data to the client.
In many cases we just have the lambda call the other lambda. It’s the easiest way to do it.
You should only try to be more fancy about it if there’s something else going on such as
your expected number of invocations is so high that the cost of lambdaA waiting on the result of lambdaB is significantly more than the additional AWS + developer cost.
your latency requirements for lambdaA are very tight.