Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get sub 10ms response times from AWS DynamoDB?

In the DynamoDB documentation and in many places around the internet I've seen that single digit ms response times are typical, but I cannot seem to achieve that even with the simplest setup. I have configured a t2.micro ec2 instance and a DynamoDB table, both in us-west-2, and when running the command below from the aws cli on the ec2 instance I get responses averaging about 250 ms. The same command run from my local machine (Denver) averages about 700 ms.

aws dynamodb get-item --table-name my-table --key file://key.json

When looking at the CloudWatch metrics in the AWS console it says the average get latency is 12 ms though. If anyone could tell me what I'm doing wrong or point me in the direction of information where I can solve this on my own I would really appreciate it. Thanks in advance.

like image 607
bschnelle Avatar asked Jan 01 '16 00:01

bschnelle


People also ask

How can I speed up DynamoDB query?

You can increase your DynamoDB throughput by several times, by parallelizing reads/writes over multiple partitions. Use DynamoDB as an attribute store rather than as a document store. This will not only reduce the read/write costs but also improve the performance of your operations considerably.

How do you read DynamoDB metrics?

To view metrics (console)Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/ . In the navigation pane, choose Metrics. You can also select Usage namespace to view DynamoDB usage metrics.

Does DynamoDB have low latency?

Introduction. When building applications that require single-digit millisecond performance, your best option is to go with a scalable serverless solution backed by DynamoDB. DynamoDB has very low latency (taken to complete an operation) in its operations, with delays ranging from 10 to 20 ms.

Is DynamoDB TTL real time?

What is DynamoDB TTL? DynamoDB allows you to specify a time-to-live timestamp attribute in an epoch timestamp format to define when the item is no longer needed. This attribute will tell DynamoDB to remove items whose TTL attribute is later than current time.


1 Answers

The response times you are seeing are largely do to the cold start times of the aws cli. When running your get-item command the cli has to get loaded into memory, fetch temporary credentials (if using an ec2 iam role when running on your t2.micro instance), and establish a secure connection to the DynamoDB service. After all that is completed then it executes the get-item request and finally prints the results to stdout. Your command is also introducing a need to read the key.json file off the filesystem, which adds additional overhead.

My experience running on a t2.micro instance is the aws cli has around 200ms of overhead when it starts, which seems inline with what you are seeing.

This will not be an issue with long running programs, as they only pay a similar overhead price at start time. I run a number of web services on t2.micro instances which work with DynamoDB and the DynamoDB response times are consistently sub 20ms.

like image 189
Ryan Fitzgerald Avatar answered Oct 10 '22 03:10

Ryan Fitzgerald