Reputation: 3330
I would like to use Cassandra to store session related informations. I do not have real HTTP session - it's different protocol, but the same concept.
Memcached would be fine, but I would like to additionally persist data.
Cassandra setup:
Map<String,Set<String,String>>
)Data example:
session1:{ // CF row key
{prop1:val1, TTL:10 min},
{prop2:val2, TTL:10 min},
.....
{propXXX:val3, TTL:10 min}
},
session2:{ // CF row key
{prop1:val1, TTL:10 min},
{prop2:val2, TTL:10 min},
},
......
sessionXXXX:{ // CF row key
{prop1:val1, TTL:10 min},
{prop2:val2, TTL:10 min},
}
In this case consistency is not a problem, but the performance could be, especially disk IO.
Since data in my session leaves for short time, I would like to avoid storing it on hard drive - except for commit log.
I have some questions:
Thank you, Maciej
Upvotes: 6
Views: 3628
Reputation: 3330
Here is what I did - and it works fine:
gc_grace to 0
- means delete columns on first compaction. This is fine, since data is not replicated.In this setup, data will be read from memtable and cache will be not used. Memtable can allocate enough heap to keep my data until it expires or even longer.
After flushing data to SSTable, compaction will immediately remove expired rows, since gc_grace=0
.
Upvotes: 3
Reputation: 5358
Considering your use case if I'm not wrong you wish to have all your key value[sessionID=>sessionData] pairs in memory and those values will expire every 10min[Means you don't want persistence].
Then why can't you try something like redis which is a in-memory store.
From Doc:
Redis is an open source, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.
Since u don't need replication redis master slave architecture even might not affect you
Redis supports TTL also
AFAIK cassandra is good for wide fat rows[More columns less rows] rather skinny rows[transpose of previous]. Your use case doesn't seem so.
Regards, Tamil
Upvotes: 1