ScyllaDB (written in C++)
ScyllaDB is a distributed wide-column database compatible with the
Cassandra
API.
Stores data internally using
LSM Trees
noSQL databases scale horizontally due to
LSM Trees,
while SQL(BTree) donot scale horizontally
Super fast, it uses:
Seaster Framework
C++ has predictable latency as no
Garbage Collector Pauses
wrt Cassandra(written in Java).
How ScyllaDB uses Seastar framework to store data?
Seastar framework binds(CPU
affinity) 1 thread per CPU core with no IPC between threads making 1
thread as independent server(with its own RAM, disk etc)
Shard (in ScyllaDB terminology): An individual CPU core inside a
single Node(Physical machine), along with the dedicated RAM and
network thread tied to that core
When ScyllaDB starts on a server with 10 physical CPU cores, it
launches 10 independent engine threads. It uses CPU affinity to lock
(bind) Thread 0 to Core 0, Thread 1 to Core 1, and so on.
|----------------------------Physical Machine-------------------------------------|
| |
| RAM |0-25| |26-50| |51-75| |76-100| |
| /\ /\ /\ /\ |
| |---- Core 0 -----| |---- Core 1 -----| |---- Core 2 -----| |---- Core 3 -----| |
| | Thread 0 | | Thread 1 | | Thread 2 | | Thread 3 | |
| | Hashes ending 00| | Hashes ending 01| | Hashes ending 02| | Hashes ending 03| |
| |-----------------| |-----------------| |-----------------| |-----------------| |
| |
|---------------------------------------------------------------------------------|
user_id = "Alice" --> |Hash| = 1042 -> 1042 % 4 = 2 (Shard 2)
Thread 2 (pinned to Core 2) processes and writes Alice's location data into Core 2's dedicated RAM buffer.