AWS Lambda如何处理多个请求? [英] How does AWS Lambda serve multiple requests?

查看:660
本文介绍了AWS Lambda如何处理多个请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

AWS Lambda如何处理多个请求?
我想知道它是一个多线程类型的模型吗?

How does AWS Lambda serve multiple requests? I want to know is it a multi-thread kind of a model here as well?

如果我从API网关调用Lambda。并且在10秒内向API发出1000个请求。将创建多少个容器以及多少个线程。

If I am calling a Lambda from an API gateway. And there are 1000 requests in 10 secs to the API. How many containers will be created and how many threads.

推荐答案


AWS Lambda如何为多个请求提供服务?

How does AWS Lambda serve multiple requests?

独立。


我想要要知道它是一个多线程类型的模型吗?

I want to know is it a multi-thread kind of a model here as well?

不,它不是一个多线程模型在你要问的意义上。

No, it is not a multi-threaded model in the sense that you are asking.

当然,你的代码可以编写为使用多个线程和/或子进程来完成任何事情目的是为一个调用完成,但Lambda不会一次向同一个容器发送多个调用。在第一次调用完成之前,容器不会用于第二次调用。如果第二个请求在第一个请求运行时到达,则第二个请求将在另一个容器中运行。

Your code can, of course, be written to use multiple threads and/or child processes to accomplish whatever purpose it is intended to accomplish for one invocation, but Lambda doesn't send more than one invocation at a time to the same container. The container is not used for a second invocation until the first one finishes. If a second request arrives while a first one is running, the second one will run in a different container.


如果我正在调用Lambda来自API网关。并且在10秒内向API发出1000个请求。将创建多少个容器以及多少个线程?

If I am calling a Lambda from an API gateway. And there are 1000 requests in 10 secs to the API. How many containers will be created and how many threads?

将根据处理每个到达的请求创建许多容器在自己的容器中。

As many containers will be created as are needed to process each of the arriving requests in its own container.

每次调用的持续时间将是最大的决定因素。

The duration of each invocation will be the largest determinant of this.

1000秒内非常快速的请求在1秒内大致相当于100个请求。假设每个请求在不到1秒的时间内完成,并且到达时间均匀分布,则可以预期创建的容器少于100个。

1000 very quick requests in 10 seconds are roughly equivalent to 100 requests in 1 second. Assuming each request finishes in less than 1 second and arrival times are evenly-distributed, you could expect fewer than 100 containers to be created.

另一方面,如果1000个请求在10秒内到达并且每个请求需要30秒才能完成,那么在此事件期间您将有1000个容器。

On the other hand, if 1000 requests arrived in 10 seconds and each request took 30 seconds to complete, you would have 1000 containers in existence during this event.

在交通量增加导致集装箱数量膨胀之后,他们都会徘徊几分钟,如果到达则准备好处理额外的负载,然后Lambda将开始终止他们。

After a spike in traffic inflates the number of containers, they will all tend to linger for a few minutes, ready to handle the additional load if it arrives, and then Lambda will start terminating them.

这篇关于AWS Lambda如何处理多个请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆