distributed-systems

Dragonfly DB

Architecture

  • Multi-threaded
  • Uses multiple fibres (similar to goroutines), schedules them and processes them via threads
  • Shared Nothing Architecture

Shared Nothing Architectures

Keyspace is sharded into n parts. n = number of cpu cores

Each thread gets it own keyspace (several mutually exclusive hash tables handled by their own thread).

This makes dragonfly an orchestrated group of redis processes.

Minimal locking and synchronisation

  • uses message bus (similar to queue all the threads can access)

All communications happen through the message bus

Situation:

  • When an IO thread needs to read from a hash table, it doesn’t access the hash table directly, but instead puts the event it in a message bus, which reaches the correct data thread that owns the hash table, does the operation, and puts the request back in the message bus to reach the IO thread.
  • This is done to avoid locks as much as possible.
  • All communication between all the threads happens through the message bus.

Data structures

  • Sorted sets
  • Dash tables

Resources

General Resources

  1. https://www.dragonflydb.io/blog/transactions-in-dragonfly
  2. https://www.youtube.com/watch?v=GsuxpMTnDRM
  3. https://github.com/dragonflydb/dragonfly/blob/main/docs/df-share-nothing.md
  4. https://www.scylladb.com/product/technology/shard-per-core-architecture/