https://github.com/escalopa/raft-kv
A raft-based key-value store
https://github.com/escalopa/raft-kv
Last synced: 2 months ago
JSON representation
A raft-based key-value store
- Host: GitHub
- URL: https://github.com/escalopa/raft-kv
- Owner: escalopa
- License: mit
- Created: 2024-09-13T21:02:11.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-01-03T21:55:49.000Z (5 months ago)
- Last Synced: 2025-01-19T15:20:04.570Z (4 months ago)
- Language: Go
- Homepage:
- Size: 291 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# raft-kv 🗃️
A **raft** based **key-value** store.

## Motivation 💫
- Learn Raft in depth
## Demo ❤️🔥
**[YOUTUBE](https://youtu.be/01LryhHyKDk)**
## Prerequisites 📚
- [task](https://taskfile.dev/#/installation)
- [docker-compose](https://docs.docker.com/compose/install/)## Run 🚀
Start the raft cluster
```bash
task docker-up
```Start the UI
```bash
task ui
```### Endpoint 🧭
| App | Endpoint |
|-----------|-------------------------|
| UI | |
| Dozzle | |
| Portainer | |## API 📖
- [raft](./api/raft/raft.proto)
- [kv](./api/kv/kv.proto)## Config ⚙️
**[2X]** = Value used in the code is randomly selected within the interval [VALUE, 2 * VALUE).
| Config | Description | Default |
|-----------------------------|--------------------------------------------------------------------------------------------------------------------------|-------------|
| LOG_LEVEL | The log level for the zap logger | INFO |
| RAFT_ID | Unique node identifier within the cluster | NULL |
| RAFT_CLUSTER | Comma-separated list of servers in the format `[RAFT_ID@HOST:PORT]` | NULL |
| RAFT_REQUEST_VOTE_TIMEOUT | Timeout (in ms) for the gRPC RequestVote method | 150 |
| RAFT_APPEND_ENTRIES_TIMEOUT | Timeout (in ms) for the gRPC AppendEntries method | 150 |
| RAFT_COMMIT_PERIOD | Interval (in ms) at which committed messages are applied to the state machine **[2X]** | 50 |
| RAFT_START_DELAY | Initial delay (in ms) before starting the Raft protocol, allowing time for cluster nodes to initialize **[2X]** | 1500 |
| RAFT_ELECTION_TIMEOUT | Duration (in ms) to wait for a leader's heartbeat before transitioning to candidate state **[2X]** | 300 |
| RAFT_STALE_PERIOD | Maximum duration (in ms) between the leader's contact with a follower before declaring the follower unreachable **[2X]** | 200 |
| RAFT_HEARTBEAT_PERIOD | Frequency (in ms) of heartbeat messages sent to followers **[2X]** | 50 |
| RAFT_HEARTBEAT_BATCH_SIZE | Maximum number of log entries to include in a single heartbeat message | 10000 |
| BADGER_ENTRY_PATH | Filesystem path for storing the Raft log entries | /data/entry |
| BADGER_STATE_PATH | Filesystem path for storing the Raft protocol state | /data/state |
| BADGER_KV_PATH | Filesystem path for storing the key-value state machine data | /data/kv |---
