Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS BatchGetItem vs GetItem in a loop

I want to retrieve 500 items and I know their primary keys. Is calling BatchGetItem more efficient than calling GetItem in a loop in dynamodb?

like image 384
Neeraj Gupta Avatar asked Oct 05 '15 19:10

Neeraj Gupta


1 Answers

yes it is. For GetItem you are going to pay the network roundtrip penalty for every item. for batch you are only going to pay it once (or 2-3-4-et times if you need to paginate).

so at 5ms per request * 500 = 2500ms extra time spend on getting the items. (5ms assumes you are in the same region as dynamo endpoint)

if you are outside of the region/aws expect this to take way more (sometimes by an order of magnitude)

like image 59
Mircea Avatar answered Sep 28 '22 17:09

Mircea