[英]good way (with low latency) to get items from multiple dynamodb tables?
I have several dynamodb tables, table A, table B, table C and table D.我有几个 dynamodb 表,表 A,表 B,表 C 和表 D。
I want to get item A from table A, item B from table B, item C from table C and item D from table D.我想从表 A 中获取项目 A,从表 B 中获取项目 B,从表 C 中获取项目 C,从表 D 中获取项目 D。
Currently I make 4 dynamodb getItem calls to 4 tables to get the items sequentially.目前我对 4 个表进行 4 次 dynamodb getItem 调用以按顺序获取项目。 Each call cost ~12 millisecond, total ~50 millisecond.
每次通话花费约 12 毫秒,总计约 50 毫秒。
ItemA a = tableA.getItem("A");
ItemB b = tableB.getItem("B");
ItemC c = tableC.getItem("C");
ItemD d = tableD.getItem("D");
Is there a better way to make the calls to reduce latency?有没有更好的方法来减少延迟? Not sure how i can make it parallel here.
不知道我怎样才能让它在这里平行。
If the requests, as in your example, are not dependent on one another - in other words, you don't need to know the result of the first request to send the second, you don't need to do them sequentially (one after another) - you can start all four in parallel.如果请求(如您的示例所示)彼此不依赖 - 换句话说,您无需知道第一个请求的结果即可发送第二个请求,则无需按顺序执行(一个之后)另一个)-您可以同时启动所有四个。
How to start four requests in parallel depends on the specific programming you are using, but you have an even easier option: Send just one BatchGetItem
request - with the four requests in it.如何并行启动四个请求取决于您使用的特定编程,但您有一个更简单的选择:只发送一个
BatchGetItem
请求 - 其中包含四个请求。 DynamoDB will do all these requests in parallel for you. DynamoDB 将为您并行处理所有这些请求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.