简体   繁体   English

2 个线程是否会同时访问我的 Java AWS Lambda?

[英]Will 2 threads ever access my Java AWS Lambda concurrently?

Does AWS maintain a thread-pool and dispatch concurrent incoming requests to the same Lambda instance, or spin up another instance in these circumstances? AWS 是否维护线程池并将并发传入请求分派到同一个 Lambda 实例,或者在这些情况下启动另一个实例?

I know that at some load factor another instance will be started, but can I rely on single-threaded access within a Lambda?我知道在某个负载因子下将启动另一个实例,但是我可以依赖 Lambda 中的单线程访问吗?

A Lambda instance processes one event at the time.一个 Lambda 实例一次处理一个事件。 If more events arrive before the event is processed, a new instance is spawned.如果在处理事件之前有更多事件到达,则会产生一个新实例。 Copied from the AWS Lambda developer guide :复制自AWS Lambda 开发人员指南

The first time you invoke your function, AWS Lambda creates an instance of the function and runs its handler method to process the event.第一次调用函数时,AWS Lambda 会创建函数的实例并运行其处理程序方法来处理事件。 When the function returns a response, it sticks around to process additional events.当函数返回响应时,它会继续处理其他事件。 If you invoke the function again while the first event is being processed, Lambda creates another instance.如果您在处理第一个事件时再次调用该函数,Lambda 将创建另一个实例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM