My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Project Information
Members
Featured
Downloads

Memcache Persistent Cluster

This library includes PHP classes to define a memcached cluster, with a persistent storage.

Imagine the next scenario:

a) You have a cluster with several www servers, and you don't have a load balancer with sticky sessions, or maybe you have it, but you really want to share the load between servers. So sticky sessions is not the best option. Or

b) You have public servers and you want to do dns load balancing.

But the thing is that you don't want to keep only some sessions, you want to save sessions for months, so this cache storage must be much bigger than a couple of GB. And of course, it must be fast!

In these situations, you usually save the user sessions in a fast storage, and where all your servers can access, which is usually memcached. Sharedance would be an option, but:

a) If you use 1 sharedance server, it's a single point of failure. If this server goes down, we loose all the cached data.

b) If you use 2 sharedance servers, they should share a common filesystem. But if this filesystem is down ( any network problem, or the server with that filesystem crashes) you loose all the data, because it's saved in the filesystem.

At this point, Memcached is the key. The first step is create a memcached cluster , saving the keys with fail tolerancy.This means that every key is saved in 2 nodes.

With 2 memcached servers we have failover, but the total available space is the same as having only local memcached.

Now we arrive at the case that a session is removed from memcached, because the available size is completely used, but you need it to keep in any persistent storage, like a database or shared filesystem, so when your customer comes back you remember him.

Then, my friend, we arrive at this project. Our project is designed to provide you the right tools to solve this problem in your PHP application.

In the first version, for persistent storage we only had filesystem based class. So it means that our servers must share any nfs directory. All the writes to persistent storage are executed in background, so you don't have to worry about performance. Filesystem consistancy is not a problem in this approach, because the same key will only be written from one instance at each time. For the next version, maybe we define a mutex for the writing process.

The second version includes Data Base persistent storage. So we will have many tables where we storage the sessions, usually there is a database exclusively for this purpose. for Version 3, we are preparing a cluster client sql class, so access ( read and write ) will be done randomly to any of the mysql hosts in the database cluster. We have in mind another storage systems like mogilefs from danga , and hdfs ( hadoop ) , for future implementations. We are also looking at sphinx specification for this purposes. After some benchmarking maybe we will include it.

Powered by Google Project Hosting