如何从 AWS DynamoDB 获得低于 10 毫秒的响应时间? [英] How to get sub 10ms response times from AWS DynamoDB?

查看:15
本文介绍了如何从 AWS DynamoDB 获得低于 10 毫秒的响应时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 DynamoDB 文档和 Internet 上的许多地方,我看到单位数毫秒的响应时间是典型的,但即使使用最简单的设置,我似乎也无法实现.我已经在 us-west-2 中配置了一个 t2.micro ec2 实例和一个 DynamoDB 表,当从 ec2 实例上的 aws cli 运行以下命令时,我得到平均大约 250 毫秒的响应.从我的本地机器(丹佛)运行相同的命令平均大约需要 700 毫秒.

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

在 AWS 控制台中查看 CloudWatch 指标时,它显示平均获取延迟为 12 毫秒.如果有人能告诉我我做错了什么或指出我可以自己解决这个问题的信息方向,我将不胜感激.提前致谢.

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.

推荐答案

您看到的响应时间很大程度上取决于 aws cli 的冷启动时间.运行 get-item 命令时,cli 必须加载到内存中,获取临时凭证(如果在 t2.micro 实例上运行时使用 ec2 iam 角色),并建立与 DynamoDB 服务的安全连接.完成所有这些之后,它会执行 get-item 请求,最后将结果打印到 stdout.您的命令还需要从文件系统中读取 key.json 文件,这会增加额外的开销.

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.

我在 t2.micro 实例上运行的经验是,aws cli 在启动时有大约 200 毫秒的开销,这似乎与您所看到的一致.

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.

这对于长时间运行的程序来说不是问题,因为它们只在启动时支付类似的间接费用.我在与 DynamoDB 一起使用的 t2.micro 实例上运行了许多 Web 服务,而 DynamoDB 响应时间始终低于 20 毫秒.

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.

这篇关于如何从 AWS DynamoDB 获得低于 10 毫秒的响应时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆