简体   繁体   English

为什么从 AWS SDK 创建客户端会挂起 AWS Lambda

[英]Why creating client from AWS SDK hangs AWS Lambda

Exactly this line hangs lambda, and causes it to timeout.正是这一行挂起 lambda,并导致它超时。 Credentials and permissions seems right:凭据和权限似乎是正确的:

AmazonSimpleDBClient sdb = new AmazonSimpleDBClient(credentials);

I experienced this same issue and found my solution by increasing the memory and timeout settings for my lambda.我遇到了同样的问题,并通过增加我的 lambda 的内存和超时设置找到了我的解决方案。

Lambda allocates CPU resources relative to the amount of memory you allocate for your service. Lambda 会根据您为服务分配的内存量分配 CPU 资源。 In my case, I kept my memory setting low because my process didn't need more, but I changed it when I realized it does need more CPU - due to the Java based cryptographic implementations (using https and AWS credentials)就我而言,我将内存设置保持在较低水平,因为我的进程不需要更多内存,但是当我意识到它确实需要更多 CPU 时,我更改了它 - 由于基于 Java 的加密实现(使用 https 和 AWS 凭证)

It appears that the node.js AWS apis are much less CPU intensive than the Java AWS SDK.与 Java AWS SDK 相比,node.js AWS api 对 CPU 的占用似乎要少得多。 In my test, I create both a node.js and Java Lambda that simply did a Describe on an empty SimpleDB domain.在我的测试中,我创建了一个 node.js 和 Java Lambda,它们只是在一个空的 SimpleDB 域上进行了描述。 From my observations, with the maximum memory setting, the best case execution time for both was around 300ms, but the worse case was 3 and 15 seconds respectively.根据我的观察,在最大内存设置下,两者的最佳情况执行时间约为 300 毫秒,但最坏情况分别为 3 秒和 15 秒。

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

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