tags:

views:

418

answers:

1

I have been working in trying to optimize a webservice that is required to return somewhat quickly (less than 1 second) and is required to maintain a high load of requests (greater than 1000/second). We are using memcached as a way to store objects "in memory". It seems we are getting a large number of timeout errors from memcache.

[Thu Jul 23 22:59:42 2009] [error] [client 123.456.789.10] PHP Warning: Memcache::connect() [memcache.connect]: Can't connect to 127.0.0.1:11211, Connection timed out (110)

So, on to the questions.

  1. Is a good use of memcache to store objects in memory that are time consuming to create? Would APC be a better location for these objects? The number of reads and

  2. Are there common pitfalls that I am overlooking in setting up memcache to work more efficiently?

Thanks for any help, I am somewhat new to working with memcache, and I think there is something I am missing.

+3  A: 

To answer your first point :

  • The power of memcached is that it allows to create a cluster of cache servers : it is not meant to be used on a single server (event it you can use it that way)
    • the theory is you have many servers, and each one has some free RAM you have no use for
    • to use this RAM, you install memcached on these servers, and configure it to use the amount of RAM that wasn't used
    • and if one machine is down, it automatically stops using it, and put load balance the data on the others
    • the drawback of memcached (for some people) is that it's network based (even when you use it on only one machine) ; which means a bit slower that "local-only"
  • APC works on only one machine : it is great (used as a caching mecanism) to store data you only need on one server, or if you only have one server ; and don't have more data that what you can store in RAM.
    • main drawback would be that it absolutly does'nt scale : it's thought for one machine ; if you have 10, you will have to have the same data 10 times, one time on each machine.
    • APC is said to be about 5 times faster to get data, as it's local, and non-network-based.

One thing to about APC : if you use it for it's opcode cache ability (you should), make sure you configure it to have enough RAM for opcode+cache (so that it doesn't run out of memory for opcode cache, which would be bad)

If you need more (specific) help with memcached and don't get much help here, there is a mailing-list, which is sometimes quite active ; maybe trying there could be useful.

Pascal MARTIN