Socket Performance

Grant Edwards grante at visi.com
Thu Mar 13 14:38:26 EDT 2008


On 2008-03-13, sleddd at gmail.com <sleddd at gmail.com> wrote:

>> > For example: try creating a local client/server (running on the same
>> > computer) where the server sends the client a fixed amount of data.
>> > Using method A, recv(8192) and sendall( ) with 8192 bytes
>> > worth of data. Do this 100 times. Using method B, recv(1) and
>> > sendall( ) with 1 byte worth of data. Do this 819200 times.
>>
>> > If you time both methods, method A has much greater
>> > throughput than method B.
>>
>> Why is it faster to drink a liter of water a cupful at a time than to
>> drink it out of an eyedropper?

> Well, lets say you have a situation where you're going to be
> alternating between sending large and small chunks of data. Is the
> solution to create a NetworkBuffer class and only call send when the
> buffer is full, always recv(8192)?

If you need to send large and small chumks of data, the
solution is to send large and small chunks of data.

-- 
Grant




More information about the Python-list mailing list