Done |
Area |
Category |
Question |
Blobs |
Use Metadata |
Are you storing frequently used metadata in blob metadata to avoid having to download each blob to extract it each time? | |
Blobs |
Uploading Fast |
To upload one blob fast, are you uploading blocks in parallel? | |
Tables |
Configuration |
Are you using JSON for your table requests? | |
Tables |
Limiting Returned Data |
Are you using projection to avoid retrieving unneeded properties? | |
Queues |
Update Message |
Are you using UpdateMessage to store progress in processing a message and avoid having to reprocess from the start if the processing component encounters an error? | |
Queues |
Architecture |
Are you using queues to make your entire application more scalable by keeping long-running workloads out of the critical path and scale them independently? |
Example Scenarios
Many of the recommendations in the checklist are simple to implement in your code. Here are three examples, each of which may have a significant effect on the performance of your application if you apply them in the correct context: Scenario #1: Queues: Configuration Have you turned Nagle off to improve the performance of small requests? The Nagle algorithm is enabled by default. To disable it for a queue endpoint, you can use the following code. This code must execute before you make any calls to the queue endpoint:var storageAccount = CloudStorageAccount.Parse(connStr); ServicePoint queueServicePoint = ServicePointManager.FindServicePoint(storageAccount.QueueEndpoint); queueServicePoint.UseNagleAlgorithm = false; CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();Scenario #2: Blobs: Copying Blobs Are you copying blobs in an efficient manner? To copy blob data from a container in one storage account to a container in another storage account, you could first download and then upload the data as shown here:
CloudBlockBlob srcBlob = srcBlobContainer.GetBlockBlobReference("srcblob"); srcBlob.DownloadToFile(@"C:\Temp\copyblob.dat",System.IO.FileMode.Create); CloudBlockBlob destBlob = destBlobContainer.GetBlockBlobReference("destblob"); destBlob.UploadFromFile(@"C:\Temp\copyblob.dat", System.IO.FileMode.Open);However, a much more efficient approach is to use one of the copy blob methods such as StartCopyFromBlob as shown here:
CloudBlockBlob srcBlob = srcBlobContainer.GetBlockBlobReference("srcblob"); CloudBlockBlob destBlob = destBlobContainer.GetBlockBlobReference("destblob"); destBlob.StartCopyFromBlob(GenerateSASUri(srcBlob));
Note that this example uses a Shared Access Signature (SAS) to access the private blob in the source container.Scenario #3: Blobs: Uploading Fast When trying to upload one blob quickly, are you uploading blocks in parallel? If you are using the .NET Storage Client Library, it has the capability to manage parallel block uploads for you. The following code sample shows how you can use the BlobRequestOptions class to specify the number of threads to use for a parallel block upload (four in this example):
CloudBlockBlob blob = srcBlobContainer.GetBlockBlobReference("uploadinparallelblob"); byte[] buffer = ... var requestOptions = new BlobRequestOptions() { ParallelOperationThreadCount = 4 }; blob.UploadFromByteArray(buffer, 0, buffer.Length, null, requestOptions);
Note that the Storage Client Library may upload small blobs as a single blob upload instead of multiple block uploads: the SingleBlobUploadThresholdInBytes property of the BlobRequestOptions class sets the size threshold above which the Storage Client Library uses block uploads.