Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.49k stars 4.82k forks source link

Inconsistent performance issue in Azure Blob Storage Premium ZRS #43819

Open Murugaa19 opened 6 months ago

Murugaa19 commented 6 months ago

Library name and version

Azure.Storage.Blobs (12.15.0)

Query/Question

We are facing inconsistent performance issues repeatedly in Azure Blob Storage, particularly in the asynchronous copy blob process. Below is the code snippet we're using for copying:

We're initiating start copy requests that are queuing on the Azure storage without being processed. We aren't even receiving a server request ID to track the asynchronous operations, and without this ID, we're unable to cancel the requests that have already been initiated.

Sometimes, all requests are completed in milliseconds, while at other times, it takes more than 1 minute. Therefore, we included a workaround network timeout retry after 5 seconds. Now, most of the requests are taking 3-5 seconds and when retry it is getting completed in milliseconds.

Also, at that time, our service's CPU and memory usage are below 10%, so we don’t face any high load.

Provide a solution to resolve this performance issues.

Details:

Azure Storage Account

Premium (Performance), Zone-redundant storage (Replication)

 

SDK

Azure.Storage.Blobs (12.15.0)

 

Code used:

private static async Task CopyContainerAsync(

BlobContainerClient sourceContainer,

int pageSize,

BlobContainerClient targetContainer,

List excludedBlobs = default)

{

var i = 0;

 

await foreach (var batchItems in sourceContainer.GetBlobsAsync().AsPages(pageSizeHint: 100))

{

var batchTasks = new List();

foreach (var item in batchItems.Values)

{

if (excludedBlobs?.Contains(item.Name) == true)

{

continue;

}

 

BlobClient blob = sourceContainer.GetBlobClient(item.Name);

BlobClient targetBlob = targetContainer.GetBlobClient(blob.Name);

batchTasks.Add(targetBlob.StartCopyFromUriAsync(blob.Uri));

}

 

await Task.WhenAll(batchTasks).ConfigureAwait(false);

}

}

BlobClient blob = sourceContainer.GetBlobClient(item.Name);

BlobClient targetBlob = targetContainer.GetBlobClient(blob.Name);

await targetBlob.StartCopyFromUriAsync(blob.Uri, cancellationToken: cancellationToken)).configureawait(false);

 

 

services.AddAzureClients(builder =>

{

builder.AddBlobServiceClient(EnvironmentVariables.AzureBlobStorage)

.ConfigureOptions(options =>

{

options.Retry.MaxRetries = 5;

options.Retry.NetworkTimeout = TimeSpan.FromSeconds(5);

});

});

Inconsistent Behavior in Copy Blob:

Aspose Words e9ebf2b5-c5c0-4f9c-a280-f17e0800938f 001

Aspose Words e9ebf2b5-c5c0-4f9c-a280-f17e0800938f 002

Environment

No response

github-actions[bot] commented 6 months ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @xgithubtriage.