Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/gensmusic/dragonboat

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/gensmusic/dragonboat

  • v0.0.0-20190323032803-bb370152294c
  • Source
  • Go
  • Socket score

Version published
Created
Source

dragonboat

Dragonboat - A Multi-Group Raft library in Go / 中文版

license Build status travis-ci Go Report Card Godoc Join the chat at https://gitter.im/lni/dragonboat

About

Dragonboat is a high performance multi-group Raft consensus library in Go with C++11 binding support.

Consensus algorithms such as Raft provides fault-tolerance by alllowing a system continue to operate as long as the majority member servers are available. For example, a Raft cluster of 5 servers can make progress even if 2 servers fail. It also appears to clients as a single node with strong data consistency always provided. All running servers can be used to initiate read requests for aggregated read throughput.

Dragonboat handles all technical difficulties associated with Raft to allow users to just focus on their application domains. It is also very easy to use, our step-by-step examples can help new users to master it in half an hour.

Features

  • Easy to use API for building Raft based applications in Go or C++
  • Feature complete and scalable multi-group Raft implementation
  • Fully pipelined and TLS mutual authentication support, ready for high latency open environment
  • Custom Raft log storage and Raft RPC support, easy to integrate with latest I/O techs
  • Optional Drummer server component for managing large number of Raft groups with high availability
  • Extensively tested including using Jepsen's Knossos linearizability checker, some results are here

Most features covered in Diego Ongaro's Raft thesis have been supported -

  • leader election, log replication, snapshotting and log compaction
  • membership changes
  • ReadIndex protocol for read-only queries
  • leadership transfer and non-voting members
  • idempotent updates transparent to applications
  • batching and pipelining

Performance

Dragonboat is the fastest open source multi-group Raft implementation on Github.

For 3-nodes system using mid-range hardware, e.g. 22 cores Intel Xeon at 2.8Ghz and enterprise NVME SSD (details here), Dragonboat can sustain at 9 million writes per second when the payload is 16bytes each or 11 million mixed I/O per second at 9:1 read:write ratio. High throughput is maintained in geographically distributed environment. When the RTT between nodes is 30ms, 2 million I/O per second can still be achieved using a much larger number of clients. throughput

The number of concurrent active Raft groups affects the overall throughput as requests become harder to be batched. On the other hand, having thousands of idle Raft groups has a much smaller impact on throughput. nodes

Table below shows write latencies in millisecond, Dragonboat has <5ms P99 write latency when handling 8 million writes per second at 16 bytes each. Read latency is lower than writes as the ReadIndex protocol employed for linearizable reads doesn't require fsync-ed disk I/O.

OpsPayload Size99.9% percentile99% percentileAVG
1m162.241.190.79
1m12811.111.370.92
1m102471.6125.913.75
5m164.641.951.16
5m12836.616.551.96
8m1612.014.652.13

When tested on a single Raft group, Dragonboat can sustain writes at 1.25 million per second when payload is 16 bytes each, average latency is 1.3ms and the P99 latency is 2.6ms. This is achieved when using an average of 3 cores (2.8GHz) on each server.

As visualized below, Stop-the-World pauses caused by Go1.11's GC are sub-millisecond on highly loaded systems. Such very short Stop-the-World pause time is further significantly reduced in Go 1.12. Golang's runtime.ReadMemStats reports that less than 1% of the available CPU time is used by GC on highly loaded system. stw

Requirements

  • x86_64 Linux or MacOS, Go 1.11 or 1.12, GCC or Clang with C++11 support
  • RocksDB 5.13.4 or above when using RocksDB for storing Raft logs

Getting Started

Note that, steps below use code from the Master branch. Master is our unstable branch for development. Please use released versions for any production purposes.

To download Dragonboat to your Go workspace:

$ go get -u -d github.com/lni/dragonboat

You need to decide whether to use RocksDB or LevelDB to store Raft logs. RocksDB is recommended.

RocksDB

If RocksDB 5.13.4 or above has not been installed, use the following commands to install RocksDB 5.13.4 to /usr/local/lib and /usr/local/include.

$ cd $GOPATH/src/github.com/lni/dragonboat
$ make install-rocksdb-ull

Run built-in tests to check the installation:

$ cd $GOPATH/src/github.com/lni/dragonboat
$ make dragonboat-test

To build your application

CGO_CFLAGS="-I/path/to/rocksdb/include" CGO_LDFLAGS="-L/path/to/rocksdb/lib -lrocksdb" go build -v pkgname

LevelDB

Nothing need to be installed when using LevelDB based Raft Log storage.

To run built-in tests using LevelDB based storage:

$ cd $GOPATH/src/github.com/lni/dragonboat
$ DRAGONBOAT_LOGDB=leveldb make dragonboat-test

To build the your application using LevelDB based Raft log storage

go build -v -tags="dragonboat_leveldb" pkgname

Optional - C++ binding

The C++ binding is only required when you want to use Dragonboat in your C++ project. To install the C++ binding:

$ cd $GOPATH/src/github.com/lni/dragonboat
$ make binding
$ sudo make install-binding

Run C++ binding tests (gtest is required):

$ cd $GOPATH/src/github.com/lni/dragonboat
$ make clean
$ make test-cppwrapper

FAQ, docs, step-by-step examples and online chat are available.

Examples

Dragonboat examples are here.

Status

Dragonboat is production ready.

Contributing

For reporting bugs, please open an issue. For contributing improvements or new features, please send in the pull request.

License

Dragonboat is licensed under the Apache License Version 2.0. See LICENSE for details.

Third party code used in Dragonboat and their licenses is summarized here.

FAQs

Package last updated on 23 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc