Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top