{"id":15194800,"url":"https://github.com/databendlabs/openraft","last_synced_at":"2025-05-14T09:13:27.754Z","repository":{"id":37014866,"uuid":"367261349","full_name":"databendlabs/openraft","owner":"databendlabs","description":"rust raft with improvements","archived":false,"fork":false,"pushed_at":"2025-05-08T12:21:47.000Z","size":11404,"stargazers_count":1545,"open_issues_count":61,"forks_count":171,"subscribers_count":31,"default_branch":"main","last_synced_at":"2025-05-08T13:29:47.499Z","etag":null,"topics":["consensus","distributed-systems","raft"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/databendlabs.png","metadata":{"files":{"readme":"README.md","changelog":"change-log.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-05-14T05:45:16.000Z","updated_at":"2025-05-08T12:21:50.000Z","dependencies_parsed_at":"2023-01-17T13:32:24.595Z","dependency_job_id":"16c6abc6-4981-4555-81d5-20653daf03ea","html_url":"https://github.com/databendlabs/openraft","commit_stats":{"total_commits":1132,"total_committers":37,"mean_commits":"30.594594594594593","dds":"0.26413427561837455","last_synced_commit":"39a81ee0efa67aeb5f6dcc3a8c5a04d16df6dee6"},"previous_names":["databendlabs/openraft"],"tags_count":73,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/databendlabs%2Fopenraft","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/databendlabs%2Fopenraft/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/databendlabs%2Fopenraft/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/databendlabs%2Fopenraft/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/databendlabs","download_url":"https://codeload.github.com/databendlabs/openraft/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253773205,"owners_count":21962187,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["consensus","distributed-systems","raft"],"created_at":"2024-09-27T23:02:01.638Z","updated_at":"2025-05-14T09:13:27.743Z","avatar_url":"https://github.com/databendlabs.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n    \u003ch1\u003eOpenRaft\u003c/h1\u003e\n    \u003ch4\u003e\n        Advanced \u003ca href=\"https://raft.github.io/\"\u003eRaft\u003c/a\u003e in 🦀 Rust using \u003ca href=\"https://tokio.rs/\"\u003eTokio\u003c/a\u003e. Please ⭐ on \u003ca href=\"https://github.com/databendlabs/openraft\"\u003egithub\u003c/a\u003e!\n    \u003c/h4\u003e\n\n\n[![Crates.io](https://img.shields.io/crates/v/openraft.svg)](https://crates.io/crates/openraft)\n[![docs.rs](https://docs.rs/openraft/badge.svg)](https://docs.rs/openraft)\n[![DeepWiki](https://img.shields.io/badge/DeepWiki-openraft-blue.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAyCAYAAAAnWDnqAAAAAXNSR0IArs4c6QAAA05JREFUaEPtmUtyEzEQhtWTQyQLHNak2AB7ZnyXZMEjXMGeK/AIi+QuHrMnbChYY7MIh8g01fJoopFb0uhhEqqcbWTp06/uv1saEDv4O3n3dV60RfP947Mm9/SQc0ICFQgzfc4CYZoTPAswgSJCCUJUnAAoRHOAUOcATwbmVLWdGoH//PB8mnKqScAhsD0kYP3j/Yt5LPQe2KvcXmGvRHcDnpxfL2zOYJ1mFwrryWTz0advv1Ut4CJgf5uhDuDj5eUcAUoahrdY/56ebRWeraTjMt/00Sh3UDtjgHtQNHwcRGOC98BJEAEymycmYcWwOprTgcB6VZ5JK5TAJ+fXGLBm3FDAmn6oPPjR4rKCAoJCal2eAiQp2x0vxTPB3ALO2CRkwmDy5WohzBDwSEFKRwPbknEggCPB/imwrycgxX2NzoMCHhPkDwqYMr9tRcP5qNrMZHkVnOjRMWwLCcr8ohBVb1OMjxLwGCvjTikrsBOiA6fNyCrm8V1rP93iVPpwaE+gO0SsWmPiXB+jikdf6SizrT5qKasx5j8ABbHpFTx+vFXp9EnYQmLx02h1QTTrl6eDqxLnGjporxl3NL3agEvXdT0WmEost648sQOYAeJS9Q7bfUVoMGnjo4AZdUMQku50McDcMWcBPvr0SzbTAFDfvJqwLzgxwATnCgnp4wDl6Aa+Ax283gghmj+vj7feE2KBBRMW3FzOpLOADl0Isb5587h/U4gGvkt5v60Z1VLG8BhYjbzRwyQZemwAd6cCR5/XFWLYZRIMpX39AR0tjaGGiGzLVyhse5C9RKC6ai42ppWPKiBagOvaYk8lO7DajerabOZP46Lby5wKjw1HCRx7p9sVMOWGzb/vA1hwiWc6jm3MvQDTogQkiqIhJV0nBQBTU+3okKCFDy9WwferkHjtxib7t3xIUQtHxnIwtx4mpg26/HfwVNVDb4oI9RHmx5WGelRVlrtiw43zboCLaxv46AZeB3IlTkwouebTr1y2NjSpHz68WNFjHvupy3q8TFn3Hos2IAk4Ju5dCo8B3wP7VPr/FGaKiG+T+v+TQqIrOqMTL1VdWV1DdmcbO8KXBz6esmYWYKPwDL5b5FA1a0hwapHiom0r/cKaoqr+27/XcrS5UwSMbQAAAABJRU5ErkJggg==)](https://deepwiki.com/databendlabs/openraft)\n[![guides](https://img.shields.io/badge/guide-%E2%86%97-brightgreen)](https://docs.rs/openraft/latest/openraft/docs/index.html)\n[![Discord Chat](https://img.shields.io/discord/1015845055434588200?logo=discord)](https://discord.gg/ZKw3WG7FQ9)\n\u003cbr/\u003e\n[![CI](https://github.com/databendlabs/openraft/actions/workflows/ci.yaml/badge.svg)](https://github.com/databendlabs/openraft/actions/workflows/ci.yaml)\n[![Coverage Status](https://coveralls.io/repos/github/databendlabs/openraft/badge.svg?branch=main)](https://coveralls.io/github/databendlabs/openraft?branch=main)\n![License](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue)\n![Crates.io](https://img.shields.io/crates/d/openraft.svg)\n![Crates.io](https://img.shields.io/crates/dv/openraft.svg)\n\n\u003c/div\u003e\n\nThis project intends to improve raft as the next-generation consensus protocol for distributed data storage systems (SQL, NoSQL, KV, Streaming, Graph ... or maybe something more exotic).\n\nCurrently, openraft is the consensus engine of meta-service cluster in [databend](https://github.com/databendlabs/databend).\n\n\n- 🚀 **Get started**:\n    - [OpenRaft guide](https://docs.rs/openraft/latest/openraft/docs/getting_started/index.html) is the best place to get started,\n    - [OpenRaft docs](https://docs.rs/openraft/latest/openraft/docs/index.html) for more in-depth details,\n    - [OpenRaft FAQ](https://docs.rs/openraft/latest/openraft/docs/faq/index.html) explains some common questions.\n    - [OpenRaft on DeepWiki](https://deepwiki.com/databendlabs/openraft) provides detailed architectural documentation to help understand OpenRaft internals.\n\n- 💡 **Example Applications**:\n\n    - [Examples with OpenRaft 0.9](https://github.com/databendlabs/openraft/tree/release-0.9/examples) require OpenRaft 0.9 on [crate.io/openraft](https://crates.io/crates/openraft)\n    - [Examples with OpenRaft 0.10](https://github.com/databendlabs/openraft/tree/release-0.10/examples) require OpenRaft 0.10, which is not yet published on crate.io;\n\n- 🙌 **Questions**?\n    - Why not take a peek at our [FAQ](https://docs.rs/openraft/latest/openraft/docs/faq/index.html)? You might find just what you need.\n    - Wanna chat? Come hang out with us on [Discord](https://discord.gg/ZKw3WG7FQ9)!\n    - Or start a new discussion over on [GitHub](https://github.com/databendlabs/openraft/discussions/new).\n    - Or join our [Feishu group](https://applink.feishu.cn/client/chat/chatter/add_by_link?link_token=d20l9084-6d36-4470-bac5-4bad7378d003).\n    - And hey, if you're on WeChat, add us: `drmingdrmer`. Let's get the conversation started!\n\nWhatever your style, we're here to support you. 🚀 Let's make something awesome together!\n\n- OpenRaft is derived from [async-raft](https://docs.rs/crate/async-raft/latest) with several bugs fixed: [Fixed bugs](https://github.com/databendlabs/openraft/blob/main/derived-from-async-raft.md).\n\n\n# Status\n\n- The features are almost complete for building an application.\n- Performance: Supports 70,000 writes/sec for single writer, and 1,000,000 writes/sec for 256 writers. See: [Performance](#performance)\n- Unit test coverage stands at 92%.\n- The chaos test has not yet been completed, and further testing is needed to ensure the application's robustness and reliability.\n\n\n## API status\n\n- **OpenRaft API is not stable yet**. Before `1.0.0`, an upgrade may contain incompatible changes.\n  Check our [change-log](https://github.com/databendlabs/openraft/blob/main/change-log.md). A commit message starts with a keyword to indicate the modification type of the commit:\n\n  - `DataChange:` on-disk data types changes, which may require manual upgrade.\n  - `Change:` if it introduces incompatible changes.\n  - `Feature:` if it introduces compatible non-breaking new features.\n  - `Fix:` if it just fixes a bug.\n\n## Versions\n\n- **Branch main** has been under active development.\n    The main branch is for the [release-0.10](https://github.com/databendlabs/openraft/tree/release-0.10).\n\n- **Branch [release-0.9](https://github.com/databendlabs/openraft/tree/release-0.9)**:\n  Latest: ( [v0.9.0](https://github.com/databendlabs/openraft/tree/v0.9.0) | [Change log](https://github.com/databendlabs/openraft/blob/release-0.9/change-log.md#v090) );\n  Upgrade guide: ⬆️  [0.8 to 0.9](https://docs.rs/openraft/0.9.0/openraft/docs/upgrade_guide/upgrade_08_09/index.html);\n  `release-0.9` **Won't** accept new features but only bug fixes.\n\n- **Branch [release-0.8](https://github.com/databendlabs/openraft/tree/release-0.8)**:\n  Latest: ( [v0.8.8](https://github.com/databendlabs/openraft/tree/v0.8.8) | [Change log](https://github.com/databendlabs/openraft/blob/release-0.8/change-log.md#v088) );\n  Upgrade guide: ⬆️  [0.7 to 0.8](https://docs.rs/openraft/0.8.4/openraft/docs/upgrade_guide/upgrade_07_08/index.html), ⬆️  [0.8.3 to 0.8.4](https://docs.rs/openraft/0.8.4/openraft/docs/upgrade_guide/upgrade_083_084/index.html);\n  `release-0.8` **Won't** accept new features but only bug fixes.\n\n- **Branch [release-0.7](https://github.com/databendlabs/openraft/tree/release-0.7)**:\n  Latest: ( [v0.7.6](https://github.com/databendlabs/openraft/tree/v0.7.6) | [Change log](https://github.com/databendlabs/openraft/blob/release-0.7/change-log.md#v076) );\n  Upgrade guide: ⬆️  [0.6 to 0.7](https://docs.rs/openraft/0.8.4/openraft/docs/upgrade_guide/upgrade_06_07/index.html);\n  `release-0.7` **Won't** accept new features but only bug fixes.\n\n- **Branch [release-0.6](https://github.com/databendlabs/openraft/tree/release-0.6)**:\n  Latest: ( [v0.6.8](https://github.com/databendlabs/openraft/tree/v0.6.8) | [Change log](https://github.com/databendlabs/openraft/blob/release-0.6/change-log.md) );\n  `release-0.6` **won't** accept new features but only bug fixes.\n\n# Roadmap\n\n- [x] **2022-10-31** [Extended joint membership](https://docs.rs/openraft/latest/openraft/docs/data/extended_membership/index.html)\n- [x] **2023-02-14** Minimize confliction rate when electing;\n  See: [OpenRaft Vote design](https://docs.rs/openraft/latest/openraft/docs/data/vote/index.html);\n  Or use standard raft mode with [feature flag `single-term-leader`](https://docs.rs/openraft/latest/openraft/docs/feature_flags/index.html).\n- [x] **2023-04-26** Goal performance is 1,000,000 put/sec.\n- [ ] Reduce the complexity of vote and pre-vote: [get rid of pre-vote RPC](https://github.com/databendlabs/openraft/discussions/15);\n- [ ] Support flexible quorum, e.g.: [Hierarchical Quorums](https://zookeeper.apache.org/doc/r3.5.9/zookeeperHierarchicalQuorums.html)\n- [ ] Consider introducing read-quorum and write-quorum,\n  improve efficiency with a cluster with an even number of nodes.\n\n\n\u003c!--\n   - - [ ] Consider to separate log storage and log order storage.\n   -   Leader only determines and replicates the index of log entries, not log\n   -   payload.\n      --\u003e\n\n# Performance\n\nThe benchmark is focused on the OpenRaft framework itself and is run on a\nminimized store and network. This is **NOT a real world** application benchmark!!!\n\n| clients | put/s         | ns/op      |\n| --:     | --:           | --:        |\n| 256     | **1,014,000** |      985   |\n|  64     |   **730,000** |    1,369   |\n|   1     |      70,000   | **14,273** |\n\n\nFor benchmark detail, go to the [./cluster_benchmark](./cluster_benchmark) folder.\n\n# Features\n\n- **Async and Event-Driven**: Operates based on Raft events without reliance on periodic ticks, optimizing message batching for high throughput.\n- **Extensible Storage and Networking**: Customizable via `RaftLogStorage`, `RaftStateMachine` and `RaftNetwork` traits, allowing flexibility in choosing storage and network solutions.\n- **Unified Raft API**: Offers a single `Raft` type for creating and interacting with Raft tasks, with a straightforward API.\n- **Cluster Formation**: Provides strategies for initial cluster setup as detailed in the [cluster formation guide](https://docs.rs/openraft/latest/openraft/docs/cluster_control/cluster_formation/index.html).\n- **Built-In Tracing Instrumentation**: The codebase integrates [tracing](https://docs.rs/tracing/) for logging and distributed tracing, with the option to [set verbosity levels at compile time](https://docs.rs/tracing/latest/tracing/level_filters/index.html).\n\n## Functionality:\n\n- ✅ **Leader election**: by policy or manually([`trigger_elect()`][]).\n- ✅ **Non-voter(learner) Role**: refer to [`add_learner()`][].\n- ✅ **Log Compaction**(snapshot of state machine): by policy or manually([`trigger_snapshot()`]).\n- ✅ **Snapshot replication**.\n- ✅ **Dynamic Membership**: using joint membership config change. Refer to [dynamic membership](https://docs.rs/openraft/latest/openraft/docs/cluster_control/dynamic_membership/index.html)\n- ✅ **Linearizable read**: [`ensure_linearizable()`][].\n- ⛔️ **Wont support**: Single-step config change.  \u003c!-- TODO: explain why --\u003e\n- ✅ Toggle heartbeat / election: [`enable_heartbeat`][] / [`enable_elect`][].\n- ✅ Trigger snapshot / election manually: [`trigger_snapshot()`][] / [`trigger_elect()`][].\n- ✅ Purge log by policy or manually: [`purge_log()`][].\n\n\n# Who use it\n\n- [Databend](https://github.com/databendlabs/databend) - The Next-Gen Cloud [Data+AI] Analytics\n- [CnosDB](https://github.com/cnosdb/cnosdb) - A cloud-native open source distributed time series database.\n- [yuyang0/rrqlite](https://github.com/yuyang0/rrqlite) - A rust implementation of [rqlite](https://github.com/rqlite/rqlite).\n- [raymondshe/matchengine-raft](https://github.com/raymondshe/matchengine-raft) - A example to demonstrate how openraft persists snapshots/logs to disk.\n- [Helyim](https://github.com/helyim/helyim) - [SeaweedFS](https://github.com/seaweedfs/seaweedfs) implemented in pure Rust.\n- [RobustMQ](https://github.com/robustmq/robustmq) - Next generation cloud-native converged message queue.\n\n# Contributing\n\nCheck out the [CONTRIBUTING.md](https://github.com/databendlabs/openraft/blob/main/CONTRIBUTING.md)\nguide for more details on getting started with contributing to this project.\n\n## Contributors\n\n\u003ca href=\"https://github.com/databendlabs/openraft/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=databendlabs/openraft\"/\u003e\n\u003c/a\u003e\n\nMade with [contributors-img](https://contrib.rocks).\n\n# License\n\nOpenRaft is licensed under the terms of the [MIT License](https://en.wikipedia.org/wiki/MIT_License#License_terms)\nor the [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0), at your choosing.\n\n\n[`change_membership()`]: https://docs.rs/openraft/latest/openraft/raft/struct.Raft.html#method.change_membership\n[`add_learner()`]: https://docs.rs/openraft/latest/openraft/raft/struct.Raft.html#method.add_learner\n[`purge_log()`]: https://docs.rs/openraft/latest/openraft/raft/struct.Raft.html#method.purge_log\n\n[`enable_heartbeat`]: https://docs.rs/openraft/latest/openraft/struct.Config.html#structfield.enable_heartbeat\n[`enable_elect`]: https://docs.rs/openraft/latest/openraft/struct.Config.html#structfield.enable_elect\n\n[`trigger_elect()`]: https://docs.rs/openraft/latest/openraft/raft/struct.Raft.html#method.trigger_elect\n[`trigger_snapshot()`]: https://docs.rs/openraft/latest/openraft/raft/struct.Raft.html#method.trigger_snapshot\n[`ensure_linearizable()`]: https://docs.rs/openraft/latest/openraft/raft/struct.Raft.html#method.ensure_linearizable\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatabendlabs%2Fopenraft","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatabendlabs%2Fopenraft","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatabendlabs%2Fopenraft/lists"}