title: Loading data into DynamoDB table always throttles
body: <p>I am quite new to DynamoDB and NodeJS, so I wanted to have a play with this. But I'm kinda getting thrown off a little bit when I tried to load data into a table.</p>
  
  <p>I created a table which has 1 read capacity unit and 1 write capacity unit, and I've got a json dataset that contains 10,000 items. Each item contains only one key/value pair, so the size of an item is quite small, around 50 bytes or so. I have a simple function in NodeJS that reads the file, loop them through, and for each item, I call <code>putItem</code> api to write it to the dynamodb table.</p>
  
  <p>When I run it, it all looked fine until some point, it started to throttle out requests. It keeps saying "provisioned throughput has been exceeded". Later I tried to up the write capacity unit to like 10000 (maximum), or even enable auto scaling, neither worked. The cloudwatch metric says the consumed write capacity is around 8 or something, but I can't figure out why that's the case. I just took the sample nodejs code from the AWS doc like following:</p>
  
  <pre><code>var AWS = require("aws-sdk");
  var fs = require('fs');
  
  AWS.config.update({
      region: "ap-southeast-2",
      profile: "default"
  });
  
  var docClient = new AWS.DynamoDB.DocumentClient();
  
  console.log("Importing tokens into DynamoDB. Please wait.");
  
  var allTokens = JSON.parse(fs.readFileSync('token.json', 'utf8'));
  allTokens.forEach(function(token) {
      var params = {
          TableName: "NewToken",
          Item: {
              "token":  token.token,
          }
      };
  
      docClient.put(params, function(err, data) {
         if (err) {
             console.error("Unable to add token", token.token, ". Error JSON:", JSON.stringify(err, null, 2));
         } else {
             console.log("PutItem succeeded:", token.token);
         }
      });
  });
  </code></pre>
  
  <p>The dataset looks like this</p>
  
  <pre><code>[
      {"token": "kmxgar0b91"},
      {"token": "pzbljf0s9q"},
      {"token": "24j052s72z"},
      {"token": "xg2b9s4tk7"},
      {"token": "g1268hs4re"},
      ....
  ]
  </code></pre>
  
  <p>The error I can see from running the script is like this:</p>
  
  <pre><code>Unable to add token vv8wtryxmz . Error JSON: {
    "message": "The level of configured provisioned throughput for the table was exceeded. Consider increasing your provisioning level with the UpdateTable API.",
    "code": "ProvisionedThroughputExceededException",
    "time": "2018-02-21T12:04:52.779Z",
    "requestId": "RE6UTK0RBM47VUSEBIUBIUTHBRVV4KQNSO5AEMVJF66Q9ASUAAJG",
    "statusCode": 400,
    "retryable": true
  }
  </code></pre>
  
  <p>Can anyone point out what might've gone wrong with my script or my configuration with dynamodb table?</p>
  
  <p>Much appreciated.</p>