the write strategy of the client implement affects the set
performance dramatically?
Maxim Dounin
mdounin at mdounin.ru
Wed Mar 5 02:29:03 UTC 2008
Hello!
On Wed, Mar 05, 2008 at 12:54:44PM +1100, Dean Harding wrote:
> Maxim Dounin wrote:
>> You may note that first packet was ack'ed after 100ms - default delayed
>> ack timeout in FreeBSD. Since your next packet is small - OS waits before
>> sending it, and sends only after previous packet was ack'ed. And since
>> memcached don't get the whole request, it has nothing to answer - so ack
>> was sent only after timeout.
>>
>> Setting net.inet.tcp.delayed_ack to 0 makes times much more real:
>
> I would suggest that you simply send the packet in one write() call, rather
> than setting TCP_NODELAY. Since memcache has a maximum size of 1MB anyway,
> you're not going to be creating impossibly big memory buffers (hopefully).
Really, single write() call is wrong way to go. In addition to the
unneeded buffer allocations this will kill performance due to
memcpy() involved for whole data chunk.
Writev() is better, but depending on task you may not be able to
use it. E.g. for 'noreply' commands recently introduced you have
to use TCP_NODELAY anyway.
Maxim Dounin
More information about the memcached
mailing list