https://github.com/jmsadair/raft
An implementation of the Raft consensus protocol.
https://github.com/jmsadair/raft
consensus-protocol distributed-computing distributed-systems go golang grpc hacktoberfest protobuf raft raft-consensus-algorithm
Last synced: 28 days ago
JSON representation
An implementation of the Raft consensus protocol.
- Host: GitHub
- URL: https://github.com/jmsadair/raft
- Owner: jmsadair
- License: mit
- Created: 2023-01-01T17:13:59.000Z (about 3 years ago)
- Default Branch: dev
- Last Pushed: 2025-08-12T05:18:08.000Z (6 months ago)
- Last Synced: 2025-09-03T17:25:31.471Z (5 months ago)
- Topics: consensus-protocol, distributed-computing, distributed-systems, go, golang, grpc, hacktoberfest, protobuf, raft, raft-consensus-algorithm
- Language: Go
- Homepage:
- Size: 717 KB
- Stars: 38
- Watchers: 1
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README

[](https://pkg.go.dev/github.com/jmsadair/raft)


# Raft
This package provides a simple, easy-to-understand, and reliable implementation of [Raft](https://en.wikipedia.org/wiki/Raft_(algorithm)) using Go. Raft is a [consensus](https://en.wikipedia.org/wiki/Consensus_(computer_science)) protocol designed to manage replicated logs in a distributed system. Its purpose is to ensure fault-tolerant coordination and consistency among a group of nodes, making it suitable for building reliable systems. Potential use cases include distributed file systems, consistent key-value stores, and service discovery.
# Features
The following features are currently supported:
- Automated Snapshots
- Concurrent Snapshot Transfer from Leader to Followers
- Dynamic Membership Changes
- Linearizable and Lease-Based Read-Only Operations
- Prevote and Leader Stickyness
# Protocol Overview
Raft is based on a leader-follower model, where one node is elected as the leader and coordinates the replication process. Time is divided into terms, and the leader is elected for each term through a leader election process. The leader receives client requests, which are then replicated to other nodes called followers. The followers maintain a log of all state changes, and the leader's responsibility is to ensure that all followers have consistent logs by sending them entries to append. Safety is guaranteed by requiring a majority of nodes to agree on the state changes, ensuring that no conflicting states are committed.
# Installation and Usage
First, make sure you have Go `1.20` or a higher version installed on your system.
You can download and install Go from the official [Go website](https://golang.org/).
Then, install the raft package by running
```shell
go get -u github.com/jmsadair/raft
```
Once you have the package installed, you may refer to the [raft package reference page](https://pkg.go.dev/github.com/jmsadair/raft) for basic usage.
An example of how to use raft as well as a set of [Jepsen](https://github.com/jepsen-io/jepsen) tests can be found [here](https://github.com/jmsadair/raft-example).
# Contributing
Other developers are encouraged to contribute to this project and pull requests are welcome. Please read
these [guidelines](.github/CONTRIBUTING.md) if you are interested in contributing.