Skip to content

Commit

Permalink
doc: batched write
Browse files Browse the repository at this point in the history
  • Loading branch information
akiradeveloper committed Jun 8, 2024
1 parent bdf899e commit 0db8206
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions doc/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- [Multi-Raft](multi-raft.md)
- [Heartbeat Multiplexing](heartbeat-multiplexing.md)
- [Batched Write](batched-write.md)
- [Raft Process](raft-process.md)
- [Multi Threading](multi-threading.md)
- [Application State](application-state.md)
Expand Down
33 changes: 31 additions & 2 deletions redb-backend/README.md → doc/src/batched-write.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,38 @@
# redb-backend
# Batched Write

In multi-raft, multiple shards process write requests. Conceptually, each shard maintains its own log for entry insertion.

Having a physically independent log for each shard isn't efficient as each write requires a transaction to persist the data on the storage.

However, an optimization technique called "batching" can be used. Here, each shard maintains a virtual log, and the entries are temporarily queued in a shared queue. These queued entries are then processed in a single transaction, reducing the number of transactions.

This approach often presents a throughput versus latency dilemma. However, this implementation increases throughput without sacrificing latency.
This approach often presents a throughput versus latency dilemma. However, this implementation increases throughput without sacrificing latency.

```mermaid
graph LR
CLI(Client)
subgraph P1
T1(redb::Table)
end
subgraph P2
T2(redb::Table)
end
subgraph P3
T3(redb::Table)
end
subgraph Reaper
Q(Queue)
end
DB[(redb::Database)]
CLI -->|entry| T1
CLI --> T2
CLI --> T3
T1 -->|lazy entry| Q
T2 --> Q
T3 --> Q
Q -->|transaction| DB
```

0 comments on commit 0db8206

Please sign in to comment.