title: What is causing intermittent long execution times for DynamoDB operations
body: <p>We are experiencing intermittent DynamoDB execution times, taking consistently just over 10 seconds. This is happening roughly once every hour or three.</p>
  <ul>
  <li>The DynamoDB operations are called from a Node.js Lambda (either getItem or updateItem)</li>
  <li>The AWS SDK DynamoDB instance instantiation happens once outside of the Lambda handler</li>
  <li>The Lambda and DynamoDB are in the same VPC with a DynamoDB endpoint enabled</li>
  <li>The Lambda is triggered by a DynamoDB stream from another DynamoDB table which can happen multiple times a second</li>
  <li>The tables are set to PAY_PER_REQUEST</li>
  <li>The Partition Key is unique and we are getting concurrency of 4 Lambdas</li>
  <li>We have given the Lambda 2560MB of memory</li>
  <li>We have tried setting the BATCH_SIZE of the stream from 1 to 10 but it never prevents the intermittent long execution time</li>
  <li>We have enabled AWS SDK logging and can see on the long spike times that the DynamoDB call has been retried once - the duration on these occasions is consistently just over 10 seconds</li>
  <li>We have set the AWS SDK timeout from 5 secs to  2 secs and still see the 10 second delay</li>
  <li>We have maxRetries on the table set to 10</li>
  </ul>
  <p>The cause for the consistent 10 second timing of the long spikes is hard to figure out. If anyone has any other idea to try out or advice it would be much appreciated. We are also liaising with DynamoDB, Lambda and Networking AWS support departments but so far they haven't figured out what is going on.</p>
  <p>Much thanks,</p>
  <p>Sam</p>