I used Azure Queues for a project at work recently. One common suggestion is to turn off Nagle’s algorithm which coalesces small messages into larger messages. While Nagle’s algorithm can help improve network congestion, it can add significant latency when all your messages are small which tends to be the case with Azure Queue requests. The way you turn off Nagle’s algorithm is:
CloudStorageAccount account = CloudStorageAccount.Parse(connectionString); ServicePoint queueServicePoint = ServicePointManager.FindServicePoint(account.QueueEndpoint); queueServicePoint.UseNagleAlgorithm = false;
Another change, which I have not seen suggested anywhere, is to increase the ServicePoint.MaxIdleTime. This controls how long a connection can be idle before it is closed. If the time between requests exceeds the MaxIdleTime (i.e. the request rate is low), every request will need to establish a new connection which is usually over SSL. Creating a new SSL connection is an expensive operation that involves at least two round trips. By increasing the MaxIdleTime, you can re-use connections more often and avoid redoing the SSL handshake.