AWS Lambda Task timed out after 6.00 seconds

不打扰是莪最后的温柔 提交于 2019-12-05 04:08:52

The default timeout for AWS Lambda functions when using the Serverless framework is 6 seconds. Simply change that to a higher value as noted in the documentation:

functions:
  hello:
    ...
    timeout: 10 # optional, in seconds, default is 6

Since you mentioned that your DynamoDB table is provisioned with only 5 WCU this means that only 5 writes are allowed per second.

DynamoDB does offer burst capacity allowing you to use 300 seconds worth of accumulated capacity (which at 5 WCU it is equivalent to 1500 total write requests) but as soon as those are exhausted it will start to throttle.

The DynamoDB client has automatic retries built in, with exponential backoff and it is smart enough to recognize throttling so it will slow down the retries to the point that a single write can easily take several seconds to complete successfully if it is being repeatedly throttled.

Your Lambda function is very likely timing out at 6 seconds because the function is waiting on retries to Dynamo.

So, when doing load testing make sure that your dependencies are all scaled appropriately. At 1000 requests per second you should make sure to scale the Read/Write capacity allocation for your DynamoDB table(s) and/or Index(s) accordingly.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!