Skip to main content

RAFT consensus algorithm implementation

Project description

raftnode

https://img.shields.io/pypi/v/raftnode.svg Documentation Status

RAFT consensus algorithm implementation

Overview

raftnode is a fault tolerant distributed metastore based on RAFT consensus algorithm. It supports storing data in-memory and storing data in rocksdb database

It let’s you save the state of your application. Like configurations, web application sessions, or any kind of data you want to cache for faster retrieval. In a way, it’s like distributed python dictionary.

Few core features are:

  • High availability: data can be read, even in case of node failures (thanks to the RAFT consensus)

  • Replication: every data is replicated across machines

  • Stateful-ness: raftnode maintains a log which is basically sequence of commands as they come in. For example: the cluster gets 2 data insert operations, they will be logged in the exact sequence of their arrival, across the cluster

  • Namespaces: you can have different isolated categories(namespaces) to store different types of information/configurations. For example: for user sessions, you can have a namespace say ‘sessions’ that will hold just the session data And another namespace ‘configuration’ that will hold configurations like database address, microservice address, etc

  • Consistency: (thanks to RAFT consensus) I’ve tried to maintain data Consistency. In case of leader node failure, data insertions are halted until new leader node is elected (the time is few ms)

  • Bring-your-own-client: using raftnode, you can start the distributed cluster. To interact with it, you have the ability to write your own client using nodejs or scala or python or any language of your choice. There’s no language binding here.

  • Scaling: the nodes in the cluster can be added or removed at will.

When use distributed key value stores?

Whenever your application needs lots of small continuous reads and writes. For example: ecommerce cart items, product recommendations, microservice address, database configurations , etc.

raftnode is similar to redis or etcd. raftnode also lets you write your own client instead of using redis or etcd libraries.

Here are few links for further reference:

What is the library’s future potential?

Currently, it let’s you insert/update key-values, but not delete. It does not have support for snapshots or scheduled backup to some external storage like s3 (I’m not sure of its required). So a few updates in the near future are:

  • Add snapshot-ing

  • (May be) add probabilistic data structures like hyperloglog and bloom filters

  • An authentication mechanism to verify the identity of the nodes

Installation

By default, raftnode stores the data in memory. To install the vanilla version, follow these steps:

pip install raftnode

A persistent database can be used instead of the in-memory data storage. By default, raftnode uses rocksdb. To install this version of raftnode, follow these instructions:

pip install raftnode[rocksdb]

Basic Usage

  • Use in memory data store:

raftnode --ip <MY_IP:MY_PORT> --peers <PEER1:PORT1>,<PEER2:PORT2>,...,<PEERn:PORTn>
  • …OR use rocksdb database:

raftnode --ip <MY_IP:MY_PORT> --peers <PEER1:PORT1>,<PEER2:PORT2>,...,<PEERn:PORTn> --store database --volume <DIRECTORY TO STORE THE DATABASE>

For detailed command line reference, click cli usage

For detailed usage, click client usage

For more detailed CLI instructions:

raftnode --help

Features

  • TODO

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

0.1.0 (2021-07-21)

  • First release on PyPI.

0.1.1 (2021-07-26)

  • Put data into the key store

  • Get data from the key store

  • Create different namespaces for storing unique set of configurations

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

raftnode-0.1.2-py2.py3-none-any.whl (19.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file raftnode-0.1.2-py2.py3-none-any.whl.

File metadata

  • Download URL: raftnode-0.1.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.7.10

File hashes

Hashes for raftnode-0.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 84beee5ae110d22bdd6931a031c7d4d0b7f89d2ec81f9f3c128479b764a0cd24
MD5 deb167e34197b98afa1b5ac4d3f9e8d4
BLAKE2b-256 d70dda4063dcaf343506ce608782b7d5224740d7a3bdaf596e98d47348d625f6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page