First, use persistent connections. I have seen two predominant things
cause that type of behavior.
1. You just don't have enough connections available in the memcached
daemons config. Math gets confusing here if you have variable apache
processes. Your connection limit in memcached needs MaxClients *
servers + 10% based on my experience. Connections in LOCK_WAIT and
other closing states can cause more than expected connections. We are
talking about milliseconds, but it happens.
2. A firewall somewhere is limiting your connections.
Also, there are two PHP libraries and one of those has a stable and beta
branch. Which exact version are you using?
Brian.
--------
http://brian.moonspot.net/
On 1/22/10 9:31 AM, nEosAg wrote:
I have 8 memcache instances running and used default hashing policy
with failover set to False.
So, after lots of monitoring i came to know that some of my memcache
instances gets down/ connection refused to client.
I m using PHP client Library.
At times, when i checked Stats for servers then there were few
thousand connections. Then i changed my code to make connection when i
need to SET or GET any Key and after the operation close the
connection.
My Approach is Get LOCK (pseudo like adding key with lock prefix) on
Key then SET data then delete LOCK key.
Then, it minimized close to no flapping. But still there is another
problem.
Now, i wanted to knwo the status of the server before doing any GET /
SET operation as there are almost 50-100 concurrent(users) hits to
Cache so obviously there will be Data Integrity issues. So to
implement atomicity i need to know if Server is up and running then
only perform update Cahe operation otherwise do nothing to cache.
I have gone in infinite loop might over thinking it!! But as per my
requirement i need 100% consistency in Real Time :)
Please help me or guide me if my approach is wrong.
Regards,
Sagar