douxiao0400 2015-04-28 07:09
浏览 50
已采纳

Azure表存储的响应时间较慢

I'm using Azure Table Storage from my PHP application and seeing very slow response times. The application gathers reports each day for each user and places them in a partition using the partition key $userID . date("dmY"). During load testing one particular day had several thousand reports generated which requires multiple round trips to fetch due to the 1,000 entity limit in an Azure Table Storage Query. Each trip to fetch 1,000 entities can take up to 2 seconds.


Code:

for($i = 0; $i < $daysToGoBack; $i++)
{
    $filter = "PartitionKey eq '" . $userId . date("dmY", strtotime("-$i days")) . "'";

    $options = new QueryEntitiesOptions();
    $options->addSelectField('created');
    $options->setFilter(Filter::applyQueryString($filter));

    $this->benchmark->mark('main_query');

    $result = $this->tableRestProxy->queryEntities('reports', $filter, $options);

    $this->benchmark->mark('main_query_end');
    echo "Query: " . $this->benchmark->elapsed_time('main_query', 'main_query_end') . "<br/>";

    $entities = array_merge($result->getEntities(), $entities);

    $nextPartitionKey = $result->getNextPartitionKey();
    $nextRowKey = $result->getNextRowKey();

    while(!is_null($nextRowKey) && !is_null($nextPartitionKey)) 
    {
        $options = new QueryEntitiesOptions();
        $options->setNextPartitionKey($nextPartitionKey);
        $options->setNextRowKey($nextRowKey);
        $options->addSelectField('created');
        $options->setFilter(Filter::applyQueryString($filter));

        $this->benchmark->mark('sub_query');

        $newResult = $this->tableRestProxy->queryEntities('reports', $options);

        $this->benchmark->mark('sub_query_end');
        echo "Continuation: " . $this->benchmark->elapsed_time('sub_query', 'sub_query_end') . "<br/>";

        $newEntities = $newResult->getEntities();

        $entities = array_merge($newEntities, $entities);

        $nextPartitionKey = $newResult->getNextPartitionKey();
        $nextRowKey = $newResult->getNextRowKey();
    }


Result:

Query: 1.8183
Continuation: 1.2479
Continuation: 0.2423
Continuation: 0.2619
Continuation: 0.2476
Continuation: 0.2836
Continuation: 0.2345
Continuation: 0.2482
Continuation: 0.2565
Continuation: 0.2187
Continuation: 0.2319
Continuation: 0.2389
Continuation: 0.2221
Query: 0.0320
Query: 0.0338
Query: 0.1038
Query: 0.1263
Query: 0.1841
Query: 0.0547


The results above are about the best I could get out of it. The first query has almost 13,000 reports to pull back so does the initial query and then 12 calls back with the continuation token. Most of the time the queries can take much longer on exactly the same data.

Query: 1.8273
Continuation: 1.2592
Continuation: 0.8160
Continuation: 0.8463
Continuation: 0.7474
Continuation: 0.7104
Continuation: 1.3987
Continuation: 1.4321
Continuation: 1.4526
Continuation: 1.3184
Continuation: 0.7390
Continuation: 0.7212
Continuation: 0.2610
Query: 0.0630
Query: 0.1221
Query: 0.0728
Query: 0.1250
Query: 0.1717
Query: 0.0568

Are these results expected from Azure or is there a more efficient way to query this data out?

  • 写回答

1条回答 默认 最新

  • drap5081683 2015-05-14 16:27
    关注

    Have you checked out the Azure Table Storage Design guide? This might help.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘