[erlang-questions] 20k messages in 4s but want to go faster!

Johnny Billquist bqt@REDACTED
Sat Jul 11 02:25:13 CEST 2009


Michael Truog wrote:
> Matthew Sackman wrote:
>> On Sat, Jul 11, 2009 at 01:24:46AM +0200, Johnny Billquist wrote:
>>   
>>> Nagle is actually a good thing, which improves performance, not decrease it.
>>>
>>> There is one specific situation when you don't want nagle, and that
>>> is if you send very little data, and what it to be sent immediately.
>>> In that specific case, Nagle is an obstruction and should be shut
>>> off.
>>>     
>> Yup. The immediate part shouldn't be underestimated. The improvement to
>> latency can be significant. If you're doing a lot of client-server
>> communication, then disabling Nagle can improve throughput substantially
>> as the latency comes down thus permitting higher round trips per second.
>>
>> Matthew
>>   
> As clarification, disabling Nagle is best for low latency networks and
> improves throughput.  High latency networks can benefit from the
> algorithm, so it is generally used unless it is an internal cluster of
> computers.
> 
> See http://en.wikipedia.org/wiki/Nagle's_algorithm
> to see why real-time systems avoid Nagle.

Hmm, I can't see how Nagle would help if you have a high latency 
network. Don't make no sense at all. That's not what Nagle is for. 
That's what you have sliding window protocols for. And large packets, 
large windows and large buffers.

But any high volume connection will benifit from Nagle. Try turning off 
Nagle and do a file transfer, and you could become very disappointed 
with the performance.

What Nagle really aims at, is when you have an application send lots of 
small pieces of data. Without Nagle, each little bit will be send it 
it's own TCP segment. With Nagle, all those small sends will be bundled 
together in a larger TCP segment. Now, Nagle don't neccesarily delay 
data, it only delays data if you have a segment smaller than MSS, 
otherwise it will be send right away anyway, since there is no point in 
delaying that packet to try and aggregate data.

And file transfers are usually not sending data in chunks adapted to the 
MSS, but instead just sends whatever chunk size is convenient for the 
tcp implementation. Nagle will make sure that the link is used as 
efficiently as possible.

As I said from the start, the only time you should disable Nagle is if 
you are sending *little* data, and want low latency. If you have high 
volumes of data, Nagle will help you, by either not interfering at all 
(if your applicion is sending chunks larger that the MSS), or 
aggregating your data into as large IP packets as possible (thus 
reducing the protocol overhead, and thereby improving throughput).

Real time systems should probably avoid Nagle, because they should be 
very concerned with latency. More so than throughput. :-)

	Johnny

-- 
Johnny Billquist                  || "I'm on a bus
                                   ||  on a psychedelic trip
email: bqt@REDACTED             ||  Reading murder books
pdp is alive!                     ||  tryin' to stay hip" - B. Idol


More information about the erlang-questions mailing list