【问题标题】:Data transfer out in Azure storage在 Azure 存储中传出数据
【发布时间】:2017-09-29 16:21:52
【问题描述】:

在写入 azure 存储表期间我有大量数据传出,有什么原因吗?没有更多的存储操作,只有写入。 有一种操作会发生多次:

await keyRepository.InsertEntityAsync(new KeyEntity
{
    PartitionKey = item.PartitionKey,
    RowKey = item.RowKey
});

InsertEntityAsync 看起来像:

public async Task InsertEntityAsync(T entity)
{
    if (entity == null) throw new ArgumentNullException(nameof(entity));
    await _cloudTable.ExecuteAsync(TableOperation.Insert(entity));
}

_cloudTable的创建:

private readonly CloudTable _cloudTable;

CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(storageConnectionString);
TableRequestOptions tableRequestOptions = new TableRequestOptions { RetryPolicy = retryPolicy };
CloudTableClient cloudTableClient = cloudStorageAccount.CreateCloudTableClient();
cloudTableClient.DefaultRequestOptions = tableRequestOptions;
_cloudTable = cloudTableClient.GetTableReference(tableName);
_cloudTable.CreateIfNotExists();

编辑 1

读取 - 45.5 GB

写入 - 39.4 GB

【问题讨论】:

  • 如何定义“巨大”?您的图表不显示单位(我们也不知道您的插入频率,这是相关的,因为每个 REST 调用确实有某种类型的响应)。你怎么知道出站传输仅仅是从写入到表存储?
  • 根据图表,我在过去 2 天花费了 3.96 美元用于数据传输。基于price 它是 45.5 GB
  • 您要向表中写入多少数据?
  • Azure 中的指标目前存在问题,但根据价格,我写了大约 39.4 GB
  • 忘了问:你的代码在哪里运行?与您的存储帐户相同的区域,还是不同的区域?

标签: c# azure azure-storage azure-table-storage


【解决方案1】:

根据那篇文章:

https://docs.microsoft.com/en-us/rest/api/storageservices/insert-entity

实体在响应正文中返回。

如果您更喜欢保存输出带宽,可以在请求中添加以下标头:

Prefer : return-no-content

编辑 1

Prefer : return-no-content

默认发送

但可以通过以下方式控制标头的发送:

  OperationContext operationContext = new OperationContext { };
  operationContext.UserHeaders = new Dictionary<string, string> {
    { "Prefer", "return-no-content" }
  };
  table.Execute(insertOperation, null, operationContext: operationContext);

尽管如此,在我的试验中,我收到了超过 600 个字节的响应(只有标头,没有正文)

编辑 2

我也试过批量发送,但是如果请求数降低,使用的全局带宽并没有最小化

【讨论】:

  • 谢谢,看起来很有意思,不过我用的是Azure SDK,有默认值return-no-content,即使我显式设置了,数据传出也是一样的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-08-14
  • 2020-04-03
  • 2013-10-14
  • 1970-01-01
  • 2021-01-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多