{"id":13630027,"url":"https://github.com/PikaLabs/floyd","last_synced_at":"2025-04-17T13:31:16.957Z","repository":{"id":95320322,"uuid":"59819685","full_name":"PikaLabs/floyd","owner":"PikaLabs","description":"A raft consensus implementation that is simply and understandable","archived":false,"fork":false,"pushed_at":"2018-11-17T15:16:25.000Z","size":948,"stargazers_count":320,"open_issues_count":23,"forks_count":108,"subscribers_count":33,"default_branch":"master","last_synced_at":"2024-08-01T22:45:01.023Z","etag":null,"topics":["consensus","library","raft","raft-protocol"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PikaLabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-05-27T08:44:52.000Z","updated_at":"2024-07-12T14:30:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"95e2ebb4-c4f9-4f55-be5a-b7744a6893c7","html_url":"https://github.com/PikaLabs/floyd","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PikaLabs%2Ffloyd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PikaLabs%2Ffloyd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PikaLabs%2Ffloyd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PikaLabs%2Ffloyd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PikaLabs","download_url":"https://codeload.github.com/PikaLabs/floyd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223757117,"owners_count":17197498,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["consensus","library","raft","raft-protocol"],"created_at":"2024-08-01T22:01:27.627Z","updated_at":"2024-11-08T21:30:37.681Z","avatar_url":"https://github.com/PikaLabs.png","language":"C++","readme":"# Floyd [中文](https://github.com/Qihoo360/floyd/blob/master/README_CN.md)\n\n[![Build Status](https://travis-ci.org/Qihoo360/floyd.svg?branch=master)](https://travis-ci.org/Qihoo360/floyd)\n\nFloyd is an C++ library based on Raft consensus protocol. \n\n* [Raft](https://raft.github.io/) is a consensus algorithm  which is easy to understand;\n* Floyd is a **library** that could be easily embeded into users' application; \n* Floyd support consistency between cluster nodes by APIs like Read/Write/Delete; \n* Also some query and debug managment APIs： GetLeader/GetServerStatus/set_log_level\n* Floyd support lock operation upon raft consensus protocol\n\n## Users\n\n* Floyd has provided high available store for Meta cluster of [Zeppelin](https://github.com/Qihoo360/zeppelin) , which is a huge distributed key-value storage.\n* Floyd lock interface has used in our production pika_hub\n* The list will goes on.\n\n## Why do we prefer a library to a service?\n\nWhen we want to coordinate services, ZooKeeper is always a good choice. \n* But we have to maintain another service.\n* We must use its' SDK at the same time. \n\nIn our opion, a single service is much more simple than two services. As a result, an embeded library could be a better choice.   \n\n\n## Floyd's Features and APIs\n\n* APIs and [usage](https://github.com/PikaLabs/floyd/wiki/API%E4%BB%8B%E7%BB%8D%E4%B8%8E%E4%BD%BF%E7%94%A8)\n\n| type      | API             | Status  |\n| --------- | --------------- | ------- |\n| Consensus | Read            | support |\n| Consensus | Write           | support |\n| Consensus | Delete          | support |\n| Local     | DirtyRead       | support |\n| Local     | DirtyWrite      | support |\n| Query     | GetLeader       | support |\n| Query     | GetServerStatus | support |\n| Debug     | set_log_level   | support |\n\n* Raft fetaures\n\n| Language | Leader election + Log Replication | Membership Changes | Log Compaction |\n| -------- | --------------------------------- | ------------------ | -------------- |\n| C++      | Yes                               | No                 | No             |\n\n\n## Compile and Have a Try\n\n* Dependencies\n    - gcc version 4.8+ to support C++11.\n    - protobuf-devel\n    - snappy-devel\n    - bzip2-devel\n    - zlib-devel\n    - bzip2\n    - submodules:\n        - [Pink](https://github.com/PikaLabs/pink)\n        - [Slash](https://github.com/PikaLabs/slash)\n\n\n* Get source code and submodules recursively.\n```powershell\ngit clone --recursive https://github.com/Qihoo360/floyd.git\n```\n* Compile and get the libfloyd.a library\n```\nmake\n```\n\n### Example\n\nThen right now there is three examples in the example directory, go and compile in the corresponding directory\n\n####  example/simple/\n\ncontains many cases wrapped floyd into small example\n\nGet all simple example will make command, then every example will start floyd with five node\n\n```\nmake\n```\n\n1. t is a single thread wirte tool to get performance\n2. t1 is multi thread program to get performance, in this case, all the writes is from the leader node\n3. t2 is an example test node join and leave\n4. t4 is an example used to see the message passing by each node in a stable situation\n5. t5 used to test single mode floyd, including starting a node and writing data\n6. t6 is the same as t1 except that all the writes is from the follower node\n7. t7 test write 3 node and then join the other 2 node case\n\n#### example/redis/\n\nraftis is a consensus server with 5 nodes and supporting redis protocol(get/set command). raftis is an example of building a consensus cluster with floyd(floyd is a simple implementation of raft protocol). It's very simple and intuitive. we can test raftis with redis-cli, benchmark with redis redis-benchmark tools. \n\ncompile raftis with command make and then start with run.sh\n\n```\nmake \u0026\u0026 sh run.sh\n```\n\n```\n#!/bin/sh\n# start with five node\n./output/bin/raftis \"127.0.0.1:8901,127.0.0.1:8902,127.0.0.1:8903,127.0.0.1:8904,127.0.0.1:8905\" \"127.0.0.1\" 8901 \"./data1/\" 6379 \u0026\n./output/bin/raftis \"127.0.0.1:8901,127.0.0.1:8902,127.0.0.1:8903,127.0.0.1:8904,127.0.0.1:8905\" \"127.0.0.1\" 8902 \"./data2/\" 6479 \u0026\n./output/bin/raftis \"127.0.0.1:8901,127.0.0.1:8902,127.0.0.1:8903,127.0.0.1:8904,127.0.0.1:8905\" \"127.0.0.1\" 8903 \"./data3/\" 6579 \u0026\n./output/bin/raftis \"127.0.0.1:8901,127.0.0.1:8902,127.0.0.1:8903,127.0.0.1:8904,127.0.0.1:8905\" \"127.0.0.1\" 8904 \"./data4/\" 6679 \u0026\n./output/bin/raftis \"127.0.0.1:8901,127.0.0.1:8902,127.0.0.1:8903,127.0.0.1:8904,127.0.0.1:8905\" \"127.0.0.1\" 8905 \"./data5/\" 6779 \u0026\n```\n\n\n```\n└─[$] ./src/redis-benchmark -t set -n 1000000 -r 100000000 -c 20\n====== SET ======\n  1000000 requests completed in 219.76 seconds\n  20 parallel clients\n  3 bytes payload\n  keep alive: 1\n\n0.00% \u003c= 2 milliseconds\n0.00% \u003c= 3 milliseconds\n8.72% \u003c= 4 milliseconds\n95.39% \u003c= 5 milliseconds\n95.96% \u003c= 6 milliseconds\n99.21% \u003c= 7 milliseconds\n99.66% \u003c= 8 milliseconds\n99.97% \u003c= 9 milliseconds\n99.97% \u003c= 11 milliseconds\n99.97% \u003c= 12 milliseconds\n99.97% \u003c= 14 milliseconds\n99.97% \u003c= 15 milliseconds\n99.99% \u003c= 16 milliseconds\n99.99% \u003c= 17 milliseconds\n99.99% \u003c= 18 milliseconds\n99.99% \u003c= 19 milliseconds\n99.99% \u003c= 26 milliseconds\n99.99% \u003c= 27 milliseconds\n100.00% \u003c= 28 milliseconds\n100.00% \u003c= 29 milliseconds\n100.00% \u003c= 30 milliseconds\n100.00% \u003c= 61 milliseconds\n100.00% \u003c= 62 milliseconds\n100.00% \u003c= 63 milliseconds\n100.00% \u003c= 63 milliseconds\n4550.31 requests per second\n```\n#### example/kv/\n\nA simple consensus kv example contain server and client builded with floyd\n\n## Test\nfloyd has pass the jepsen test, you can get the test case here\n[jepsen](https://github.com/gaodq/jepsen)\n\n## Documents\n* [Wikis](https://github.com/PikaLabs/floyd/wiki)\n\n## Contant us\n\nAnyone who is interested in raft protocol, used floyd in your production or has wrote some article about souce code of floyd please contact me, we have a article list.\n\n* email: g-infra-bada@360.cn\n* QQ Group: 294254078\n* WeChat public: 360基础架构组 \n","funding_links":[],"categories":["C++"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPikaLabs%2Ffloyd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPikaLabs%2Ffloyd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPikaLabs%2Ffloyd/lists"}