gpt4 book ai didi

amazon-web-services - AWS Lambda中可用的虚拟处理器核心最大数量是多少?

转载 作者:行者123 更新时间:2023-12-03 10:10:49 24 4
gpt4 key购买 nike

我正在尝试找到AWS Lambda中可用的虚拟处理器核心的最大数量。官方文档暗示它会随着配置的内存量而扩展:

In the AWS Lambda resource model, you choose the amount of memory you want for your function, and are allocated proportional CPU power and other resources. For example, choosing 256MB of memory allocates approximately twice as much CPU power to your Lambda function as requesting 128MB of memory and half as much CPU power as choosing 512MB of memory.



但是,即使我配置了可请求的最大内存量,运行以下代码片段也会得到 Number of cores = 2:1536 MB。
package example;

import java.io.{ InputStream, OutputStream }

class Main {
def main(input: InputStream, output: OutputStream): Unit = {
val result = "Number of cores = " + Runtime.getRuntime().availableProcessors()
output.write(result.getBytes("UTF-8"))
}
}

那么这是怎么回事?我使用availableProcessors()错误还是错误地误解了其结果?还是需要其他一些配置以获得更多内核?

最佳答案

根据AWS Lambda documentationforum,AWS不声明AWS用于此服务的实例类型。 2014年底,AWS使用了类似于计算优化的实例。现在,AWS使用类似于通用的实例。

The CPU share dedicated to a function is based off of the fraction of its allocated memory, per each of the two cores. For example, an instance with ~ 3 GB memory available for lambda functions where each function can have up to 1 GB memory means at most you can utilize ~ 1/3 * 2 cores = 2/3 of the CPU. The details may be revisited in the future, but that is the fractional nature of our usage model.



您只能利用与内存成比例的CPU能力。尽管较低和较高的内存在同一实例中,但是它们将共享成比例的CPU能力,这是较高的内存将获得更多的CPU能力。如果您读取的CPU核心总数为2,则并不意味着您可以充分利用所有CPU。

当前,无法配置CPU。您只能调整总内存。

关于amazon-web-services - AWS Lambda中可用的虚拟处理器核心最大数量是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34135359/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com