
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
75 lines
2.4 KiB
Plaintext
75 lines
2.4 KiB
Plaintext
== Why is this an issue?
|
||
|
||
Invoking other Lambdas synchronously from a Lambda is a scalability anti-pattern. Lambdas have a maximum execution time before they timeout (15 minutes as of May 2021). Having to wait for another Lambda to finish its execution could lead to a timeout.
|
||
|
||
|
||
A better solution is to generate events that can be consumed asynchronously by other Lambdas.
|
||
|
||
|
||
=== Noncompliant code example
|
||
|
||
With AWS SDKv1
|
||
|
||
[source,java]
|
||
----
|
||
InvokeRequest invokeRequest = new InvokeRequest()
|
||
.withFunctionName("myFunction");
|
||
|
||
AWSLambda awsLambda = AWSLambdaClientBuilder.standard()
|
||
.withCredentials(new ProfileCredentialsProvider())
|
||
.withRegion(Regions.US_WEST_2).build();
|
||
|
||
awsLambda.invoke(invokeRequest); // Noncompliant
|
||
----
|
||
|
||
|
||
== Resources
|
||
|
||
* https://docs.aws.amazon.com/lambda/latest/dg/best-practices.html[Best practices for working with AWS Lambda functions]
|
||
|
||
|
||
ifdef::env-github,rspecator-view[]
|
||
|
||
'''
|
||
== Implementation Specification
|
||
(visible only on this page)
|
||
|
||
=== Message
|
||
|
||
Avoid synchronous calls to other lambdas
|
||
|
||
|
||
=== Highlighting
|
||
|
||
Function invocation
|
||
|
||
|
||
'''
|
||
== Comments And Links
|
||
(visible only on this page)
|
||
|
||
=== on 27 May 2021, 14:13:15 Janos Gyerik wrote:
|
||
To be precise, I think the title should mention "synchronously": Lambdas should not invoke other lambdas _synchronously_
|
||
|
||
|
||
The description suggests 2 alternatives. I would drop the 2nd suggestion to make the call asynchronous, because I think it's generally not a good idea, due to tight coupling. The first idea is great, I'd mention only that: A better solution is to generate events that can be consumed asynchronously by other Lambdas.
|
||
|
||
|
||
|
||
|
||
=== on 27 May 2021, 14:23:37 Alexandre Gigleux wrote:
|
||
+1 with [~janos.gyerik]
|
||
|
||
|
||
I also suggest to rewrite "As the runtime of your function is bounded, waiting for another Lambda to finish executing could cause a timeout." like this:
|
||
|
||
"Lambdas have a maximum execution time before they timeout (15 minutes as of May 2021). Having to wait for another Lambda to finish its execution could lead to a timeout".
|
||
|
||
=== on 31 May 2021, 12:04:23 Quentin Jaquier wrote:
|
||
We review the suggestions together with [~dorian.burihabwa], it makes sense to us as well.
|
||
|
||
|
||
The remaining concern is that the compliant solution is not relevant anymore and we have a hard time coming up with a new one. [~janos.gyerik] do you have an example or a link to the documentation that could help?
|
||
|
||
endif::env-github,rspecator-view[]
|