AWS Lambda Task timed out after 6.00 seconds

后端 未结 2 2001
有刺的猬
有刺的猬 2021-02-12 14:09

I am using serverless framework. My Lambda function connects to DynamoDB table for updating item in table. Read & Write capacity units of table are 5 & auto_scaling is d

2条回答
  •  误落风尘
    2021-02-12 14:36

    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.

提交回复
热议问题