35 lines
994 B
Plaintext
35 lines
994 B
Plaintext
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
|
||
|
||
----
|
||
InvokeRequest invokeRequest = new InvokeRequest()
|
||
.withFunctionName("myFunction");
|
||
|
||
AWSLambda awsLambda = AWSLambdaClientBuilder.standard()
|
||
.withCredentials(new ProfileCredentialsProvider())
|
||
.withRegion(Regions.US_WEST_2).build();
|
||
|
||
awsLambda.invoke(invokeRequest); // Noncompliant
|
||
----
|
||
|
||
|
||
== See
|
||
|
||
* https://docs.aws.amazon.com/lambda/latest/dg/best-practices.html[Best practices for working with AWS Lambda functions]
|
||
|
||
|
||
ifdef::env-github,rspecator-view[]
|
||
'''
|
||
== Comments And Links
|
||
(visible only on this page)
|
||
|
||
include::comments-and-links.adoc[]
|
||
endif::env-github,rspecator-view[]
|