Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS DynamoDB Sessions with Elasticache PHP Sessions

I have a concept that I want to get peoples opinions on for running sessions in AWS with the redundancy of DynamoDB and the speed of Elasticache.

  1. PHP stores sessions in DynamoDB.
  2. When sessions are written to DynamoDB the values are also written to Elasticache (possibly stored as JSON in one key pair for fast entire retrieval.
  3. PHP then queries Elasticache for sessions.
  4. If PHP can't find a session in Elasticache it checks DynamoDB - therefore providing a backup for node failure, cluster failure and site failure. If the session is found its written back to Elasticache (if possible) and if not a new session is created in DynamoDB.

Good, bad, messy, to complex??

like image 510
Adam Avatar asked Jan 23 '13 05:01

Adam


1 Answers

No, it's not bad/complex--that's a pretty standard usage of memcache as a write-through cache of a persistent data store. However, it's a really expensive solution from monthly AWS billing perspective.

Have you benchmarked using just DynamoDB at all? It's an SSD-backed key-value store that ought to be plenty fast enough. I say "ought to" though, because I had issues with horrible latency when I attempted to do the same thing on it. We ended up moving purely to an ElasticCache solution and simply live with the possibility of node failure. But this was for an existing application that was shoe-horned onto AWS in a hurry and was using ridiculously large session objects. I haven't had time to revisit the idea.

like image 84
jamieb Avatar answered Sep 28 '22 10:09

jamieb