简体   繁体   中英

Can I use cassandra (2.0.3) as a php session store (eg. vs redis)?

I have been googling for days and read some cassandra books. But I still havent got my answer yet. We want to evaluate this a bit more before we invest our time in a redis or riak cluster to do the php session store.

Our users are being redirected geographically over 3 datacenters (US,EU,ASIA), we run a multi datacenter cassandra in all 3 locations.

Best and most efficient for us is be able to use Cassandra as a session store so we dont have to maintain another cluster. We dont mind that users have to relog because they got redirected to a different datacenter, but want to minimize this as much as possible.

So in our scenario is cassandra technically a good option as a php session store? if yes, what is the best practice in cassandra to do this? We got php covered.

Thank you!

Cassandra could be a good session store. However, be aware of Cassandra' eventually consistent design and choose your read settings accordingly. For example, if you use the default replication factor of three then it's possible a write wouldn't have been replicated fully (to the other 2 nodes) before the next read request is executed. If your read consistency level is 1 (fastest read performance) it's possible you'll get old data back from a node that hasn't received the latest write. I'd recommend a read consistency of QUORUM or higher to avoid this problem - performance will be a bit lower than level 1 but it's a trade-off that's probably necessary in this situation.

PHP supports various methods for sessions out of the box - disk, memcached and a few others. Guessing Cassandra isn't one of them though - but you can implement your own session storage fairly easily - see this page for an explanation - http://php.net/session.customhandler

You have to implement a set of methods and tell PHP about them, or on newer versions, there's an interface you can implement - which is much nicer/cleaner!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM