Search code examples
azureazure-storageazure-blob-storageazureservicebusazure-servicebus-queues

Azure Storage and Service Bus - One Connection per Asp.Net Application or per Request?


I was wondering whether anyone knows specifically what the best practice is for using and potentially sharing or creating new connections from an Asp.Net Web Application to Azure Storage and -ServiceBus?

Basically the Asp.Net application receives file uploads, stores them in an Azure Storage Blog and sends a message to an Azure ServiceBus Queue to notify background processors.

While the background processors have persistent connections, I was wondering what the correct approach is for the frontend, Asp.Net application - should new connections be made on a per-request level to Azure Storage and likewise to the ServiceBus Queue or should I share an application-lifetime created connection for each of those two?

What's the recommended way here?


Solution

  • For the service bus side of things you should try and re-use client connections as there is an over-head associated with re-creating them. More details are in the following Microsoft article about performance on Azure Service Bus:

    Best Practices for Performance Improvements Using Service Bus Brokered Messaging

    This is less of an issue with the Azure storage client which does not manage open connections in the same way.