Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have an application (Magento) that has an abstracted session storage layer. I'm trying to visualize the best way to store sessions.

mysql Database? I'm thinking a dedicated database with a very large innodb_buffer_pool_size so its basically like RAM Cache with disk backup. I'm thinking of having a seperate DB just for sessions and put the other DB stuff on a separate DB/DB Server.

Memcache? This is great but I am a bit concerned with what happens if the server crashes? I would lose that partition of sessions with the crash because from what I understand Memcache is not distrubuted. Can I make it distrubuted? ( I was just told that I can use pecl memcache module >= 3

tmpfs memory file storage? This works but I would have to sync the session on write with all the other servers using rsync or something that detects when an write happens in that folder. I'm sure something has got to exist for this.

Other solution I am not thinking about? Would love ideas.

Thanks!

share|improve this question
    
Sounds like you are on the right track i.e. Memcache probably faster but not as persistent as in a database. For the file storage you could use a cluster file system for that (e.g. OCFS2) but the complexity of the setup probably far outweighs the benefit. Probably best to start out with a DB, no? –  HTTP500 Aug 9 '11 at 20:42

1 Answer 1

Memcache? This is great but I am a bit concerned with what happens if the server crashes? I would lose that partition of sessions with the crash because from what I understand Memcache is not distrubuted. Can I make it distrubuted? ( I was just told that I can use pecl memcache module >= 3

I'm using repcached. It is started like below:

  • on server 1:

    memcached -d -p 11211 -u memcached -m 64 -c 1024 -P /var/run/memcached.pid -x <server2_ip>

  • on server 2:

    memcached -d -p 11211 -u memcached -m 64 -c 1024 -P /var/run/memcached.pid -x <server1_ip>

Configuration for PHP Memcache extension:

extension=memcache.so
memcache.allow_failover = 1
memcache.redundancy = 1
memcache.session_redundancy=2
memcache.hash_strategy = consistent

And the session handler in php.ini:

session.save_handler = memcache
session.save_path="tcp://ip1:11211, tcp://ip2:11211"
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.