Problem with network bandwidth of Azure App Service (very slow uploads)

Andreas F 40 Reputation points
2024-05-13T04:48:32.81+00:00

My App Service (A) sends a POST request that contains a base64 encoded file to App Service B . I understand that this may seem strange, but it is needed in this case. App Service B uploads it to a Blob Storage and then returns a response. The size of the file is between 40-80mb.

The problem is that the file upload is really slow (sometimes longer than two minutes). I am trying to understand why it is so slow. I would assume that the network bandwith is quite high (the two app services are in the same region). Both app services use the S1 tier.

Here is the simplified code:

App service A Controller:

private static async Task UploadFileToAppServiceB(HttpClient client, string fileName, byte[] fileContent)
{
    var path = $"www.foo.bar/upload";
    var request = new
    {
        FileName = fileName,
        Content = fileContent,
    };
    client.Timeout = TimeSpan.FromMinutes(2);
    var response = await HandleNotFound(client.PostAsJsonAsync(path, request));
    response.EnsureSuccessStatusCode();
}


App Service B Controller:

[HttpPost("upload")]
[RequestSizeLimit(209715200)]
public async Task UploadFileToBlobStorage([FromBody] FooFile fooFile)
{
    var fileContent = fooFile.Content;
    var blobContainerClient = GetContainerClient();
    var blobClient = blobContainerClient.GetBlobClient();

    await using var memoryStream = new MemoryStream(fileContent);
    await blobClient.UploadAsync(memoryStream, true);
}

Why does App Service B take so long to respond? Is there a way I can improve this?

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,042 questions
{count} votes

Accepted answer
  1. TP 79,066 Reputation points
    2024-05-13T05:55:28.1033333+00:00

    Hi Andreas,

    I've seen major performance difference when uploading blobs between Basic/Standard and Premium. So for starters, please Scale up App Service B to P0V3 SKU or higher, then repeat test.

    Additionally, please break apart the steps and test individually to determine where the bottleneck is. For example, modify App Service B Controller so that it just accepts the incoming file, but does nothing with it (don't instantiate blob client or anything), and note time difference.

    On the storage account that you are uploading to, Monitoring - Metrics blade, please check Success E2E latency metric for the blob uploads.

    Thanks.

    -TP


0 additional answers

Sort by: Most helpful