Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure .NET Component Lifetime (CloudQueueClient, CloudQueue etc.)

If I am adding Windows Azure queue items or blob storage references from an MVC application using the .NET SDK, how long should each component stay about?

For queues we have CloudStorageAccount, CloudQueueClient and CloudQueue.

For blob storage, we have CloudStorageAccount, CloudBlobClient and CloudBlobContainer.

I am assuming that it would be best to create each component once per web request but don't really now how expensive it is to create each item. Again I am assuming that keeping the clients around between web requests using a singleton lifetime for example would not be a good plan but have nothing to go on.

like image 888
Paul Hiles Avatar asked Aug 15 '12 12:08

Paul Hiles


People also ask

What is CloudQueueClient?

Provides a client-side logical representation of the Microsoft Azure Queue service. This client is used to configure and execute requests against the Queue service.

How do I use queueClient?

Create the Queue Storage client Parse( CloudConfigurationManager. GetSetting("StorageConnectionString")); // Create the queue client CloudQueueClient queueClient = storageAccount. CreateCloudQueueClient(); Now you are ready to write code that reads data from and writes data to Queue Storage.

How do I delete messages from Azure storage queue?

To delete the message, you must have two items of data returned in the response body of the Get Messages operation: The message ID, an opaque GUID value that identifies the message in the queue. A valid pop receipt, an opaque value that indicates that the message has been retrieved.

Which type of storage blob is best for random access files?

Append blobs are ideal for scenarios such as logging data from virtual machines. Page blobs store random access files up to 8 TiB in size.


1 Answers

Those .NET objects are lightweight. None of them will allocate resources or perform network operations just by being created. It's generally not worth the effort to cache or pool them unless you create quite a lot of them.

We don't even bother to cache them on a per-requests basis - we just create them as needed and throw them away. Caching them may save you some pressure on the garbage collector, but I doubt it would be much.

like image 128
Brian Reischl Avatar answered Sep 28 '22 11:09

Brian Reischl