{"id":13511331,"url":"https://github.com/tikv/raft-rs","last_synced_at":"2025-12-12T15:00:40.574Z","repository":{"id":37450975,"uuid":"114735865","full_name":"tikv/raft-rs","owner":"tikv","description":"Raft distributed consensus algorithm implemented in Rust.","archived":false,"fork":false,"pushed_at":"2025-02-28T07:51:04.000Z","size":2754,"stargazers_count":3100,"open_issues_count":63,"forks_count":413,"subscribers_count":52,"default_branch":"master","last_synced_at":"2025-05-06T19:52:01.895Z","etag":null,"topics":["distributed-consensus-algorithms","distributed-systems","raft","rust"],"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/tikv.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2017-12-19T07:56:10.000Z","updated_at":"2025-05-06T13:18:10.000Z","dependencies_parsed_at":"2024-05-13T16:46:15.927Z","dependency_job_id":"c573b5e3-9e33-49ac-93dc-aa7637d91f40","html_url":"https://github.com/tikv/raft-rs","commit_stats":{"total_commits":518,"total_committers":78,"mean_commits":6.641025641025641,"dds":0.8185328185328186,"last_synced_commit":"10c6e9db6792b85c81784e44fc278f895d5f0ab0"},"previous_names":["pingcap/raft-rs"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tikv%2Fraft-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tikv%2Fraft-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tikv%2Fraft-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tikv%2Fraft-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tikv","download_url":"https://codeload.github.com/tikv/raft-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254020473,"owners_count":22000750,"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":["distributed-consensus-algorithms","distributed-systems","raft","rust"],"created_at":"2024-08-01T03:00:47.507Z","updated_at":"2025-12-12T15:00:35.508Z","avatar_url":"https://github.com/tikv.png","language":"Rust","funding_links":[],"categories":["General-Purpose Consensus","Rust","rust","\u003ca name=\"Rust\"\u003e\u003c/a\u003eRust"],"sub_categories":[],"readme":"# Raft\n\n[![CI](https://github.com/tikv/raft-rs/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/tikv/raft-rs/actions/workflows/ci.yml)\n[![Documentation](https://docs.rs/raft/badge.svg)](https://docs.rs/raft/)\n[![Crates.io](https://img.shields.io/crates/v/raft.svg)](https://crates.io/crates/raft)\n[![dependency status](https://deps.rs/repo/github/tikv/raft-rs/status.svg)](https://deps.rs/repo/github/tikv/raft-rs)\n\n## Problem and Importance\n\nWhen building a distributed system one principal goal is often to build in *fault-tolerance*. That is, if one particular node in a network goes down, or if there is a network partition, the entire cluster does not fall over. The cluster of nodes taking part in a distributed consensus protocol must come to agreement regarding values, and once that decision is reached, that choice is final.\n\nDistributed Consensus Algorithms often take the form of a replicated state machine and log. Each state machine accepts inputs from its log, and represents the value(s) to be replicated, for example, a hash table. They allow a collection of machines to work as a coherent group that can survive the failures of some of its members.\n\nTwo well known Distributed Consensus Algorithms are Paxos and Raft. Paxos is used in systems like [Chubby](http://research.google.com/archive/chubby.html) by Google, and Raft is used in things like [`tikv`](https://github.com/tikv/tikv) or [`etcd`](https://github.com/etcd-io/etcd). Raft is generally seen as a more understandable and simpler to implement than Paxos.\n\n## Design\n\nRaft replicates the state machine through logs. If you can ensure that all the machines have the same sequence of logs, after applying all logs in order, the state machine will reach a consistent state.\n\nA complete Raft model contains 4 essential parts:\n\n1. Consensus Module, the core consensus algorithm module;\n\n2. Log, the place to keep the Raft logs;\n\n3. State Machine, the place to save the user data;\n\n4. Transport, the network layer for communication.\n\n![The design of the Raft crate](media/the-design-of-raft-rs.png)\n\n\u003e Note: This Raft implementation in Rust includes the core Consensus Module only, not the other parts. The core Consensus Module in the Raft crate is customizable, flexible, and resilient. You can directly use the Raft crate, but you will need to build your own Log, State Machine and Transport components.\n\n## Using the raft crate\n\nYou can use raft with either [rust-protobuf](https://github.com/pingcap/rust-protobuf) or [Prost](https://github.com/tokio-rs/prost) to encode/decode gRPC messages. We use rust-protobuf by default. To use Prost, build (or depend on) Raft using the `prost-codec` feature and without default features.\n\n## Developing the Raft crate\n\n`Raft` is built using the latest version of `stable` Rust, using [the 2018 edition](https://doc.rust-lang.org/edition-guide/rust-2018/).\nMinimum supported version is `1.44.0`.\n\nUsing `rustup` you can get started this way:\n\n```bash\nrustup component add clippy\nrustup component add rustfmt\n```\n\nIn order to have your PR merged running the following must finish without error:\n\n```bash\ncargo test --all \u0026\u0026 \\\ncargo clippy --all --all-targets -- -D clippy::all   \u0026\u0026 \\\ncargo fmt --all -- --check\n```\n\nYou may optionally want to install `cargo-watch` to allow for automated rebuilding while editing:\n\n```bash\ncargo watch -s \"cargo check\"\n```\n\n### Modifying Protobufs\n\nSee [instructions](proto/README.md) in the proto subdirectory.\n\n### Benchmarks\n\nWe use [Criterion](https://github.com/japaric/criterion.rs) for benchmarking.\n\n\u003e It's currently an ongoing effort to build an appropriate benchmarking suite. If you'd like to help out please let us know! [Interested?](https://github.com/tikv/raft-rs/issues/109)\n\nYou can run the benchmarks by installing `gnuplot` then running:\n\n```bash\ncargo bench\n```\n\nYou can check `target/criterion/report/index.html` for plots and charts relating to the benchmarks.\n\nYou can check the performance between two branches:\n\n```bash\ngit checkout master\ncargo bench --bench benches -- --save-baseline master\ngit checkout other\ncargo bench --bench benches -- --baseline master\n```\n\nThis will report relative increases or decreased for each benchmark.\n\n## Acknowledgments\n\nThanks [etcd](https://github.com/etcd-io/raft) for providing the amazing Go implementation!\n\n## Projects using the Raft crate\n\n- [TiKV](https://github.com/tikv/tikv), a distributed transactional key value database powered by Rust and Raft.\n\n## Links for Further Research\n\n* [The Raft site](https://raftconsensus.github.io/)\n* [The Secret Lives of Data - Raft](http://thesecretlivesofdata.com/raft/)\n* [Raft Paper](https://raft.github.io/raft.pdf)\n* [Raft Dissertation](https://github.com/ongardie/dissertation#readme)\n* [Raft Refloated](https://www.cl.cam.ac.uk/~ms705/pub/papers/2015-osr-raft.pdf)\n* [Implement Raft in Rust](https://www.pingcap.com/blog/implement-raft-in-rust/)\n* [Using Raft in Rust at RustConf 2018](https://www.youtube.com/watch?v=MSrcdhGRsOE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftikv%2Fraft-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftikv%2Fraft-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftikv%2Fraft-rs/lists"}