title: How to improve speed of DynamoDB requests
body: <p>I've been testing out DynamoDB as a potential option for a scalable and steady throughput database for a site that will be hit pretty frequently and requires a very fast response time (&lt; 50ms). I'm seeing pretty slow responses (both locally and on an EC2 instance) for the following code:</p>
  
  <pre><code>public static void main(String[] args) {
      try {
          AWSCredentials credentials = new PropertiesCredentials(new File("aws_credentials.properties"));
          long start = System.currentTimeMillis();
          AmazonDynamoDBClient client = new AmazonDynamoDBClient(credentials);
          System.out.println((System.currentTimeMillis() - start) + " (ms) to connect");
          DynamoDBMapper mapper = new DynamoDBMapper(client);
          start = System.currentTimeMillis();
          Model model = mapper.load(Model.class, "hashkey1", "rangekey1");
          System.out.println((System.currentTimeMillis() - start) + " (ms) to load Model");
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>The connection to the DB alone takes about <code>800 (ms)</code> on average and the loading using the <code>mapper</code> takes an additional <code>200 (ms)</code>. According to <a href="http://aws.amazon.com/dynamodb/" rel="nofollow">Amazon's page about DynamoDB</a> we should expect "Average service-side latencies...typically single-digit milliseconds." I wouldn't expect the full round-trip HTTP request to add that much overhead. Are these expected numbers even on an EC2 instance?</p>