is it possible to connect to memcached and check in access phase?
Marcus Clyne
eugaia at gmail.com
Mon Feb 23 04:09:57 MSK 2009
> However, if the memcached serve is on localhost, and since the data
> you exchange is small, it should be safe to use socket in blocking mode.
>
A few months ago I wrote a basic Nginx module using both the newer
libmemcached library and the older libmemcache by Sean Chittenden to get
a value from memcached and set an Nginx variable. Both were blocking
(i.e. didn't use an asynchronous approach), and I only tested them on a
local installation of memcached. The quicker of the two was the older
libmemcache library (by quite a lot, actually), probably because the
code itself is simpler.
Typical results with simple testing (using Apache Bench and HTTPerf)
were that getting a variable using libmemcache resulted in at best being
able to serve 50-60% of the requests that is possible with a simple
filesystem-based lookup. Libmemcached was typically around 30-35% of
the rate for looking up a page on the filesystem.
The figures were something like:
4700 req/s for serving a file from disk
2500 req/s for doing a simple get from memcached and setting an Nginx
variable to the result - using libmemcache
1400 req/s for doing the above, but with libmemcached
These are off the top of my head, but I think they're more or less about
right.
This was a blocking approach, though, of course. A non-blocking
asynchronous get would give much better results.
>> When you said memcached client, doesn't it mean doing self-coding
>> network programming inside nginx ?
>
> Yes.
> But you can of course use an existing memcached client, if it is
> implemented as a C library.
> See http://code.google.com/p/memcached/wiki/Clients
>
> The new libmemcached also seems to support an asynchronous interface.
If the load on your server will be high, then I'd recommend trying to
implement it with the async interface, even though it would be a bit
more complicated to set up.
Good luck,
Marcus.
More information about the nginx
mailing list