Skip to content

An implementation of the Raft consensus algorithm to achieve reliable state replication and linearizability in distributed systems.

Notifications You must be signed in to change notification settings

danielxfeng/raft

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Raft Consensus Algorithm (Go)

An implementation of the Raft consensus algorithm in Go, including leader election, log replication, persistence, and snapshot-based log compaction.

This project was implemented following the MIT 6.824 Distributed Systems Raft labs.

Reference

Raft Protocol Overview

image Raft protocol overview

Highlights

  • Full Raft implementation: leader election, log replication, and safety checks.
  • Durable state via persistence and snapshotting for log compaction.
  • Replicated key/value store on top of Raft.
  • Sharded key/value store with a shard controller service.
  • MapReduce lab code and harness for integration testing.

Project Layout

  • src/raft: Raft core (election, append entries, persistence, snapshots).
  • src/kvraft: Replicated key/value server built on Raft.
  • src/shardctrler: Shard controller for reconfiguration.
  • src/shardkv: Sharded key/value store built on Raft.
  • src/labrpc: Simulated RPC/network layer used by the labs.
  • src/labgob: Lab-specific encoder/decoder utilities.
  • src/porcupine: Linearizability checker used by tests.
  • src/mr, src/mrapps, src/main: MapReduce implementation and test drivers.

Getting Started

This repo is organized as the MIT 6.5840 module (src/go.mod). From the repo root:

cd src
go test ./raft

Running Tests

Run tests by package (from src/):

go test ./raft
go test ./kvraft
go test ./shardctrler
go test ./shardkv

Run everything:

go test ./...

MapReduce Playground

The MapReduce harness lives in src/main. A quick smoke test:

cd src/main
bash test-mr.sh

Notes

  • This code targets the MIT 6.824 lab environment and is not production-ready.
  • The RPC layer and persistence are provided by lab utilities to focus on Raft logic.

About

An implementation of the Raft consensus algorithm to achieve reliable state replication and linearizability in distributed systems.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published