PHP Sessions in Memcache

One of my sites is outgrowing a single server and I’ve been looking into clustering and load balancing so it can continue to expand. My biggest concern (until today) was making the PHP sessions available in a distributed environment. The standard answer is to serve sessions via the database, but this site is already top heavy when it comes to database access and I don’t like the idea of adding to that.

Memcache comes up as a viable alternative (and I already use it for other types of caching) but I was concerned about a really involved setup process and was not looking forward to re-coding session handling in my application. Fortunately, I couldn’t have been more wrong! I followed the instructions from “Storing your PHP sessions using memcached” on the Dotdeb blog and had the entire system implemented on my development server in about 10 minutes. After a round of testing, I moved it out to the production server and it’s running nicely.

Total time investment was about 45 minutes and looks solid and scalable. Much better than the week or so I had originally anticipated. Go Memcache!

Comments are closed.