Repolode
hashicorp

hashicorp/raft

A Go library implementing the Raft consensus protocol for managing replicated logs and replicated state machines.

Stars
9,161
Forks
1,105
Open issues
73
Last commit
20 days ago

What is it?

raft is a Go library that implements the Raft consensus algorithm. It manages a replicated log and lets an application plug in its own finite state machine (FSM), so that multiple nodes apply the same sequence of commands and keep identical state. It is intended for building consistent, partition-tolerant (CP) distributed systems with a degree of fault tolerance.

The library handles leader election, log replication, commit tracking, and automatic snapshotting with log compaction to bound disk usage. Clusters are typically run with 3 or 5 servers, tolerating one or two node failures respectively. Membership changes are supported dynamically as long as a quorum remains available. Non-voting servers and a pluggable address provider in the transport layer are also provided.

Storage backends for the log and stable store are separate: the pure Go Bbolt-based raft-boltdb is referenced, and an MDB-based backend lives in its own repository. Metrics can be emitted through either armon/go-metrics or hashicorp/go-metrics, selected by build tag.

Key features

  • 01Leader election and log replication following the Raft protocol
  • 02Pluggable finite state machine interface for application logic
  • 03Automatic snapshotting and log compaction
  • 04Dynamic cluster membership changes and non-voting servers
  • 05Pluggable storage backends for log and stable store

Use cases

  • Building a replicated key-value store or other strongly consistent service
  • Keeping metadata consistent across a small cluster of servers
  • Adding leader-based high availability to a Go service

Quick start

  1. 1

    Check that Go 1.16+ is installed

    go version
  2. 2

    Read the Godoc documentation for the library

Things to know

  • This is a Go library, not a standalone server, so you must build your own FSM and transport around it.
  • Recommended persistent log backends (raft-mdb) are in separate repositories, and raft-mdb needs cgo.

In collections

Topics

FAQ

What is raft?
A Go library implementing the Raft consensus protocol for managing replicated logs and replicated state machines. raft is a Go library that implements the Raft consensus algorithm. It manages a replicated log and lets an application plug in its own finite state machine (FSM), so that multiple nodes apply the same sequence of commands and keep identical state. It is intended for building consistent, partition-tolerant (CP) distributed systems with a degree of fault tolerance.
Is raft free to use? What license does it have?
raft is open source under the MPL-2.0 license. Check the license terms before using it in commercial products.
Is raft still maintained?
Actively maintained. The last commit to raft was on Oct 18, 2026.
What can I use raft for?
Building a replicated key-value store or other strongly consistent service Keeping metadata consistent across a small cluster of servers Adding leader-based high availability to a Go service
How do I install raft?
Check that Go 1.16+ is installed: go version Read the Godoc documentation for the library
Where can I get raft?
The source code and installation instructions are on GitHub: https://github.com/hashicorp/raft

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects

A lightweight Java fault tolerance library offering circuit breaker, rate limiter, retry, bulkhead and time limiter decorators for functional code.

Backend & APIs#java#fault-tolerance#circuit-breaker
10.8K+3 this week1.5KJavaApache-2.0Updated 9 days ago

A Python implementation of the Circuit Breaker pattern that stops calls to failing dependencies to protect the rest of a system.

Backend & APIs#circuit-breaker#resilience#fault-tolerance
701+2 this week96PythonBSD-3-ClauseUpdated last month