gpt4 book ai didi

当尝试使用 Task.WaitAllll 同时更新多个 blob 时,Azure 存储模拟器抛出 500

转载 作者:行者123 更新时间:2023-12-03 04:25:04 25 4
gpt4 key购买 nike

当尝试同时更新多个 blob 时,我尝试使用 Task.WaitAll 来提高性能

using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
using Microsoft.WindowsAzure.Storage.RetryPolicies;
using System.Threading.Tasks;

namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse("UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://localhost.fiddler;");
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

CloudBlobContainer container = blobClient.GetContainerReference("mycontainer");

// Create the container if it doesn't already exist.
container.CreateIfNotExists();

CloudBlockBlob blockBlob1 = container.GetBlockBlobReference("myblob1");
CloudBlockBlob blockBlob2 = container.GetBlockBlobReference("myblob2");
CloudBlockBlob blockBlob3 = container.GetBlockBlobReference("myblob3");
CloudBlockBlob blockBlob4 = container.GetBlockBlobReference("myblob4");
CloudBlockBlob blockBlob5 = container.GetBlockBlobReference("myblob5");

blobClient.DefaultRequestOptions = new BlobRequestOptions()
{
RetryPolicy = new NoRetry()
};
var str = "To list the blobs in a container, first get a container reference. You can then use the container's ListBlobs method to retrieve the blobs and/or directories within it. To access the rich set of properties and methods for a returned IListBlobItem, you must cast it to a CloudBlockBlob, CloudPageBlob, or CloudBlobDirectory object. If the type is ";

Task.WaitAll(UploadBlobAsync(blockBlob1, str), UploadBlobAsync(blockBlob2, str), UploadBlobAsync(blockBlob3, str), UploadBlobAsync(blockBlob4, str), UploadBlobAsync(blockBlob5, str));
}


private static async Task UploadBlobAsync(CloudBlockBlob blob, string content)
{
await blob.UploadTextAsync(content);
}
}
}

然后我发现模拟器有时会抛出 500 异常:

HTTP/1.1 500 Server encountered an internal error. Please try again after some time.
Content-Length: 253
Content-Type: application/xml
Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-request-id: 53a5fe0c-496a-4925-b87d-48cb59a7df37
x-ms-version: 2016-05-31
Date: Fri, 26 May 2017 16:46:28 GMT

<?xml version="1.0" encoding="utf-8"?><Error><Code>InternalError</Code><Message>Server encountered an internal error. Please try again after some time.
RequestId:53a5fe0c-496a-4925-b87d-48cb59a7df37
Time:2017-05-26T16:46:28.9534026Z</Message></Error>

如果我启用入口逻辑,它会成功,但需要的时间比我想象的要长得多,而且我可以通过fiddler看到其中一个blob操作总是在第一次失败并在重试时成功

它不会每次都失败,但很有可能在 500 次时失败

这是使用模拟器 5.0 和客户端库 8.1.3 进行测试的。我没有使用 azure 云存储测试此代码。

最佳答案

我还可以使用 azure 存储模拟器 v5.0 通过 5 个 uploadblob 任务重现此问题。如果任务数量小于5,则无法重现。正如您提到的,其中一个 blob 操作总是在第一次失败。 但我无法使用 Azure 云存储重现它,它与 Azure 云存储配合良好。如果对存储模拟器有任何想法,我们可以给我们的 feedback致 Azure 团队。

关于当尝试使用 Task.WaitAllll 同时更新多个 blob 时,Azure 存储模拟器抛出 500,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44206789/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com