8000 GitHub - httpe/simple-raft: A simple Raft implementation in Python with abstract networking and storage layer
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

A simple Raft implementation in Python with abstract networking and storage layer

Notifications You must be signed in to change notification settings

httpe/simple-raft

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple-Raft (Python Raft Server)

Goals

This project is developed with the following goals in mind:

  • Implement a simple Raft algorithm in Python with an abstract networking/communication and persisted storage layer
  • Provide tools to test and trace the reliability of the implementation, including a network proxy to simulate network partition, packet drops/delays etc.

Initial Setup

This repos is tested with Python 3.10 under WSL Ubuntu:

python -m venv venv
source ./venv/bin/activate
python -m pip install -v --upgrade pip 
pip install -v -r requirements.txt

Start Servers

All options are configured in config.json.

To run 3 servers named A, B, C, and a network proxy:

Run each command in a separate terminal:

python -m raft.main ./config.json A
python -m raft.main ./config.json B
python -m raft.main ./config.json C
python -m raft.main ./config.json Proxy

Persisted databases will be written to the db/ folder.

Combining Logs

Logs will be written to logs/ folder, and you can consolidate all log files into one by:

python -m raft.monitor

This can help you understand the timeline for a particular issue across different servers.

Running Tests

You can run tests against the servers with:

python -m raft.client

We have implemented 3 generic correctness tests:

  • Read-after-Write consistency test
    1. Write to one node
    2. Read immediately another node, make sure it returns what we just wrote
  • Fault tolerant linearizable consistency test:
    1. Isolate one node out of the network
    2. Write to another node
    3. Read from a third node, make sure it returns what we wrote
    4. Resume network
    5. Read immediately the previously isolated node, make sure it returns what we wrote
  • Eventual consistency test:
    1. Isolate one node out of the network
    2. Write to another node
    3. Poll periodically and make sure that eventually all nodes return the data we wrote

, and 2 performance tests:

  • Write performance test: write 100 unique values sequentially, each to a randomly selected node
  • Read performance test: read 100 times sequentially, each to a random node

Currently these tests run against both the "Attiya, Bar-Noy, Dolev" (ABD) quorum get/set algorithm (raft/routers/abd.py), and the Raft algorithm (raft/routers/raft.py).

Both algorithms provide fault-tolerant linearizable consistency, so it will pass all the tests given that we don't try to read from the faulty node(s).

We also have a simple test for the Raft state machine, where we append fibonacci numbers sequentially only after validating (at the Raft server side) the previous state is unchanged, i.e. atomic compare and swap.

Reference

Video Lectures:

  1. Distributed Systems, Cambridge 2122 (Martin Kleppmann): Youtube
  2. Distributed Systems, MIT 6.824 (Robert Morris): Youtube

Papers:

  1. In Search of an Understandable Consensus Algorithm PDF
  2. Consensus: Bridging Theory and Practice PDF
  3. Designing Data-Intensive Applications (Martin Kleppmann)
  4. Distributed Systems (Maarten van Steen) PDF

About

A simple Raft implementation in Python with abstract networking and storage layer

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0