memcached++ - C++ API to memcached
Greg Whalin
greg@meetup.com
Wed, 9 Jun 2004 15:24:23 -0400 (EDT)
True, I would expect in memory cache to always be faster. Makes sense.
The shortcomings of this approach are pretty obvious though I think when
you start to grow to multiple machines and/or your cacheable data grows
greater than your physical memory.
greg
On Wed, 9 Jun 2004, Brad Fitzpatrick wrote:
> Date: Wed, 9 Jun 2004 12:19:05 -0700 (PDT)
> From: Brad Fitzpatrick <brad@danga.com>
> To: memcached@lists.danga.com
> Subject: Re: memcached++ - C++ API to memcached
>
> > > 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
> said.
>
> 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
>
>