DynamoDB : Slow Read when queried for first time

耗尽温柔 提交于 2019-12-24 03:12:40

问题


Following is my code :

error_log('before query'.date("H:i:s:ms"));
$response = $client->query(array(
                                 "TableName" => "user",
                                 "KeyConditions" => array(
                                 "userId" => array( "ComparisonOperator" => ComparisonOperator::EQ,
                                 "AttributeValueList" => array(
                                                               array(Type::NUMBER => 2)
                                                               ))),
                                ));
error_log('after query'.date("H:i:s:ms"));
print_r($response);

My tables Read capacity is 6 reads/sec

Output of Error logs

before query 16:05:29:0229

after query 16:05:32:0232

Question: Why it took 3 secs to read the user for first time? If I add one more query after my first query then it take less than 1 sec to respond.

Any light on the path would be helpful

-Thanks


回答1:


This can happen if you are executing this query from different region than database's instance or from local.

If you haven't uploaded file with this query to the same region as your dynamoDb then it will take some time to build connection with your DB instance. Try to upload this script on the same region's server as your DB and then try again.



来源:https://stackoverflow.com/questions/21525339/dynamodb-slow-read-when-queried-for-first-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!