如何加快Azure存储队列 [英] How to speed up Azure Storage Queue
问题描述
我已尽我所能想到的一切来提高插入速度.这实际上只是几件事,没有任何改善.
I have tried everything I can think of to increase the speed of inserts. Which is really only a couple of things with no improvement.
我需要将标识符(Int64)块发送到队列,以便我的多个工作角色都可以在该队列上工作,而不必担心并发性.
I have chunks of identifiers (Int64) that I need to send to a queue so that my multiple worker roles can work on it without having to worry about concurrency.
我尝试了foreach
循环(同时使用.ToString()
和BitConverter.GetBytes()
):
I have tried a foreach
loop (both with .ToString()
and BitConverter.GetBytes()
):
foreach(long id in ids) {
queue.AddMessage(new CloudQueueMessage(id.ToString() /*BitConverter.GetBytes(id)*/));
}
和平行的.ForAll<T>()
:
ids.AsParallel().ForAll(id => queue.AddMessage(new CloudMessage(id.ToString())));
来自同一数据中心内的local和WorkerRole的插入次数最大为每秒5次,平均每秒为4.73次.
Both from local and a WorkerRole inside the same data center, the inserts max out at 5 per second, and average 4.73 per second.
我做错什么了吗?
推荐答案
尝试在tcp堆栈上禁用Nagle,因为这会缓冲小数据包,从而导致超过1/2秒钟的延迟来传输您的内容.将其放在您的角色开始代码中:
Try disabling Nagle on the tcp stack, as this buffers small packets, resulting in upwards of 1/2-second delay shipping your content. Put this in your role start code:
ServicePointManager.UseNagleAlgorithm = false;
这篇关于如何加快Azure存储队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!