Reputation: 563
I'm trying to do some research to find the best option for sessions management in a multi-server environment and was wondering what people have found successful and why. Pros and cons.
RDBMS - Slower. Better used for other data.
Memcached - You can't take down a memcached server without losing sessions
Redis - Fixes the problem of memcached, but what about ease of scalability? Fault tolerance?
Cassandra - Has good fault tolerance. Pros and cons?
MongoDB, Others?
Thanks!
Upvotes: 12
Views: 2619
Reputation: 3151
A bit late, but maybe someone is interested in a follow up. We are using Cassandra as our session store and access it via spring-session (with a home grown spring-session-cassandra addon). Objects in the session are marshalled/unmarshalled via Kryo ( https://github.com/EsotericSoftware/kryo ).
This setup gives us a session get between 1 and 2 ms and a save under 1ms:
But depending on the ring load there are some outliers in the response time:
Upvotes: 0
Reputation: 68363
Redis - Fixes the problem of memcached, but what about ease of scalability? Fault tolerance?
Redis supports replication and upcoming cluster should also support sharding of data across multiple nodes.
Upvotes: 5
Reputation: 7001
Personally, I use Cassandra to persist php session data. It stores it in a single column on a single row with session_id:{session_data_as_json} and I set the TTL on the column so that it does garbage cleanup automatically. Works a treat.
I went with cassandra as it has all other user data already ... For caching, I enabled APC on all front end webservers and haven't had any issues ...
Is this the best approach? Not sure. it was fit for purpose for the environment, technologies and business rules I needed to fulfill. ...
Side note, I did start working on a native php -> cassandra session handler: https://github.com/sdolgy/php-cassandra-sessions -- this shows how the TTL's are set with PHPCassa and Cassandra
Upvotes: 8