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
If you use your object store for large objects and employ erasure coding and use Cassandra as your data store for small objects and use replication - you have introduced a non-trivial SLA problem. In this approach, data is protected by different guarantees.
At Glassdoor we use Cassandra to store various datasets needed by search, machine learning models and other systems. Since most of these systems are built on Java, we use Java drivers for Cassandra, for read, write and delete operations.
In case of RF = 1 a counter cache hit will cause Cassandra to skip the read before write entirely. With RF > 1 a counter cache hit will still help to reduce the duration of the lock hold, helping with hot counter cell updates, but will not allow skipping the read entirely.
The only reasonable way to make Cassandra durable is to use the synchronous batch mode committer which comes with a performance penalty. Cassandra’s high-availability guarantee is not suited for erasure coded object stores.
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
.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With