DiceDB / dice

DiceDB is a redis-compliant, in-memory, real-time, and reactive database optimized for modern hardware and for building and scaling truly real-time applications.
https://dicedb.io/
Other
6.39k stars 1k forks source link

Message Bus based architecture for making DiceDB multi-threaded #117

Open arpitbbhayani opened 4 months ago

arpitbbhayani commented 4 months ago

DiceDB will be a single process with multiple threads, and it will be designed to run on multi-core servers without any special configurations or optimizations. Let's split the in-memory data store keyspace into N shards, where N <= the number of CPU logical cores in the system. Each shard is owned and managed by a single DiceDB thread, establishing a shared-nothing architecture.

Two types of threads: IOThread and ShardThread. One thread can handle both if required. We will leverage MessageBus architecture (Channel based) for inter-thread communication. A simple Go code that demonstrates -

Here's the gist with flow I had in mind

https://gist.github.com/arpitbbhayani/6b99207464b0d9e07bd1984c5545d17d

yashs360 commented 2 months ago

@arpitbbhayani I am keen to explore this. I have some questions before I can start -

  1. Do we have a thread pool implementation already that we are looking to make better? -> Browsing through the code i think not.
  2. Where do we inject the thread pool? We have executors already. How do executors get assigned to the Shards / Threads?
arpitbbhayani commented 2 months ago

@yashs360 Go for it.

  1. We do not have a thread-pool implementation yet.
  2. This is a very fundamental change that we need to bring in. I am more keen on exploring how DragonflyDB does it - https://youtu.be/XbV1LoVsbME?si=MGQ4E2vZ6zTHRuFr.

The Gist attached has a working prototype of the same. Again, this will not just be some simple injection of threads, but a change at the fundamental execution and evaluation level.

yashs360 commented 2 months ago

@arpitbbhayani I went through your snippet and am going through the DragonFly videos now. I want to visualise the architecture / workflow you have in mind, on how the entire execution will be handled, how the Shards or Fibres will be managed etc. We should discuss this, post that we can break the task into modules to work in parallel.

arpitbbhayani commented 1 month ago

Hello @yashs360,

There has been no activity on this issue for the past 5 days. It would be awesome if you keep posting updates to this issue so that we know you are actively working on it.

We are really eager to close this issue at the earliest, hence if we continue to see the inactivity, we will have to reassign the issue to someone else. We are doing this to ensure that the project maintains its momentum and others are not blocked on this work.

Just drop a comment with the current status of the work or share any issues you are facing. We can always chip in to help you out.

Thanks again.

arpitbbhayani commented 4 weeks ago

Hello @yashs360,

There has been no activity on this issue for the past 5 days. It would be awesome if you keep posting updates to this issue so that we know you are actively working on it.

We are really eager to close this issue at the earliest, hence if we continue to see the inactivity, we will have to reassign the issue to someone else. We are doing this to ensure that the project maintains its momentum and others are not blocked on this work.

Just drop a comment with the current status of the work or share any issues you are facing. We can always chip in to help you out.

Thanks again.

manishrw commented 3 weeks ago

@arpitbbhayani I can take it up if it's up for grabs.

arpitbbhayani commented 2 weeks ago

Hello @yashs360,

There has been no activity on this issue for the past 5 days. It would be awesome if you keep posting updates to this issue so that we know you are actively working on it.

We are really eager to close this issue at the earliest, hence if we continue to see the inactivity, we will have to reassign the issue to someone else. We are doing this to ensure that the project maintains its momentum and others are not blocked on this work.

Just drop a comment with the current status of the work or share any issues you are facing. We can always chip in to help you out.

Thanks again.

arpitbbhayani commented 1 week ago

Hello @yashs360,

There has been no activity on this issue for the past 5 days. It would be awesome if you keep posting updates to this issue so that we know you are actively working on it.

We are really eager to close this issue at the earliest, hence if we continue to see the inactivity, we will have to reassign the issue to someone else. We are doing this to ensure that the project maintains its momentum and others are not blocked on this work.

Just drop a comment with the current status of the work or share any issues you are facing. We can always chip in to help you out.

Thanks again.