简体   繁体   English

AWS Lambda函数超时

[英]AWS Lambda Function Times out

I have developed a nodejs lambda function on AWS responsible for calling two backend (SOAP Services) services deployed on EC2 Machines. 我已经在AWS上开发了一个nodejs lambda函数,负责调用部署在EC2机器上的两个后端(SOAP Services)服务。

The first two calls to my lambda functions times out but the rest are fines. 对我的lambda函数的前两个调用超时,但是其余的罚款。 This event will happen again when I don't call lambda for about an hour or so. 当我大约一个小时不打电话给lambda时,此事件将再次发生。

I have read about lambda standby stuff, but I am not sure what is the right solution for this problem. 我已经阅读了有关lambda备用资料的信息,但是我不确定该问题的正确解决方案是什么。

Would you please give me your opinion on this. 请您对此发表意见。

Thanks. 谢谢。

When you call a Lambda function often, it tend to stay 'in memory', ready for the next execution - but when you don't call it for a while, the first call after that delay tends to take a lot longer to startup. 当您经常调用Lambda函数时,它往往会保留在“内存中”,为下一次执行做好准备-但是,如果一段时间不调用它,则延迟后的第一次调用往往会花很长的时间才能启动。

The typical solution is to increase the memory size for the lambda function. 典型的解决方案是增加lambda函数的内存大小。 A Lambda with more memory also gets more CPU - so even if your function will not need the extra memory, it will start faster after a cold start. 具有更多内存的Lambda也会获得更多的CPU-因此,即使您的功能不需要额外的内存,在冷启动后它也会更快地启动。

Q: How are compute resources assigned to an AWS Lambda function? 问:如何将计算资源分配给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. 在AWS Lambda资源模型中,您可以选择功能所需的内存量,并按比例分配CPU能力和其他资源。 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. 例如,选择256MB内存为Lambda函数分配的CPU能力大约是请求128MB内存的两倍,而选择512MB内存的CPU能力是请求的128MB。 You can set your memory in 64MB increments from 128MB to 1.5GB. 您可以从128MB到1.5GB以64MB的增量设置内存。

from here: https://aws.amazon.com/lambda/faqs/ 从这里: https : //aws.amazon.com/lambda/faqs/

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

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