处理函数之外的资源的 AWS 容器重用和同步
AWS Container reuse and Synchronized for resource outside of the handler function
使用 AWS 容器 reuse, I want to understand if the reuse happens when any call is pending within that container or after the call has finished. I need to declare some resources outside of the handler function and either I use synchronization and doc,但在我这样做之前,我想了解 AWS promise/contract 是什么。
lambda 不需要同步,您在处理程序外声明的所有内容都将被重新用于下一次命中相同执行环境的调用。但是不会在同一个容器中同时出现两次调用。只有在第一次调用完成后,第二次调用 才可能 进入相同的执行环境。
要查找的关键词是已经提到的 "execution environment" / "execution context"。您可能会发现 https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html and https://docs.aws.amazon.com/lambda/latest/dg/running-lambda-code.html 有帮助。
After a Lambda function is executed, AWS Lambda maintains the execution context for some time in anticipation of another Lambda function invocation. In effect, the service freezes the execution context after a Lambda function completes, and thaws the context for reuse, if AWS Lambda chooses to reuse the context when the Lambda function is invoked again
"After" 并没有使它 100% 绝对,但足够清楚,我可以确认是这种情况。
使用 AWS 容器 reuse, I want to understand if the reuse happens when any call is pending within that container or after the call has finished. I need to declare some resources outside of the handler function and either I use synchronization and doc,但在我这样做之前,我想了解 AWS promise/contract 是什么。
lambda 不需要同步,您在处理程序外声明的所有内容都将被重新用于下一次命中相同执行环境的调用。但是不会在同一个容器中同时出现两次调用。只有在第一次调用完成后,第二次调用 才可能 进入相同的执行环境。
要查找的关键词是已经提到的 "execution environment" / "execution context"。您可能会发现 https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html and https://docs.aws.amazon.com/lambda/latest/dg/running-lambda-code.html 有帮助。
After a Lambda function is executed, AWS Lambda maintains the execution context for some time in anticipation of another Lambda function invocation. In effect, the service freezes the execution context after a Lambda function completes, and thaws the context for reuse, if AWS Lambda chooses to reuse the context when the Lambda function is invoked again
"After" 并没有使它 100% 绝对,但足够清楚,我可以确认是这种情况。