memcached++ - C++ API to memcached

Brad Fitzpatrick
Wed, 9 Jun 2004 12:19:05 -0700 (PDT)

> >   Unfortunately when testing memcached with this API, we found that
> >   for our task (caching havy sql requests to database) it almost 5
> >   times slower than dumb in-process cache.
> And I can tell you why.
> If you change this:
>         _sock_write(sock, buf, buf_len);
>         _sock_write(sock, (char*)"\r\n", 2);
> to that:
>         _sock_write(sock, buf, buf_len); // buf already contains \r\n
> it will work in at least 2-3 times faster.
> I.e. writing to the socket with only ONE call should speed up it a lot.

Also, set the TCP_NODELAY sockopt and only write full buffers, as Anton

In any case, in-process caching may be faster, until you run out of memory
in a single process, or you find your application is running on 80
machines instead of 1.

- Brad