Giter Site home page Giter Site logo

redraft's Introduction

REDRAFT

RedRaft is an experimental project that allows for Redis to run in a Raft environment. It uses Finn for the Raft implementation and Redis for the state-machine providing a fault-tolerant cluster.

Getting Started

Installing

  1. Install Redis.

  2. Install RedRaft

$ go install github.com/tidwall/redraft

Optionally you can download a prebuilt zip for Mac OS which includes Redis and RedRaft.

Running

First start a single-member cluster:

$ redraft

This will start the server listening on port 7481 for client and server-to-server communication.

Next, let's set a single key, and then retrieve it:

$ redis-cli -p 7481 SET mykey "my value"
OK
$ redis-cli -p 7481 GET mykey
"my value"

Adding members:

$ redraft -p 7482 -dir data2 -join 7481
$ redraft -p 7483 -dir data3 -join 7481

That's it. Now if node1 goes down, node2 and node3 will continue to operate.

Supported Commands

get, strlen, exists, getbit, getrange, substr, mget, llen, lindex, lrange, sismember, scard, srandmember, sinter, sunion, sdiff, smembers, sscan, zrange, zrangebyscore, zrevrangebyscore, zrangebylex, zrevrangebylex, zcount, zlexcount, zrevrange, zcard, zscore, zrank, zrevrank, zscan, hget, hmget, hlen, hstrlen, hkeys, hvals, hgetall, hexists, hscan, randomkey, keys, scan, dbsize, echo, type, info, ttl, pttl, dump, object, memory, time, bitpos, bitcount, geohash, geopos, geodist, pfcount, set, setnx, setex, psetex, append, del, setbit, bitfield, setrange, incr, decr, rpush, lpush, rpushx, lpushx, linsert, rpop, lpop, brpop, brpoplpush, blpop, lset, ltrim, lrem, rpoplpush, sadd, srem, smove, spop, sinterstore, sunionstore, sdiffstore, zadd, zincrby, zrem, zremrangebyscore, zremrangebyrank, zremrangebylex, zunionstore, zinterstore, hset, hsetnx, hmset, hincrby, hincrbyfloat, hdel, incrby, decrby, incrbyfloat, getset, mset, msetnx, select, move, rename, renamenx, expire, expireat, pexpire, pexpireat, auth, flushdb, flushall, sort, persist, config, restore, migrate, bitop, geoadd, georadius, georadiusbymember, pfadd, pfmerge:

Not Supported

Cluster, Replication, and PubSub commands.

Built-in Raft Commands

Here are a few commands for monitoring and managing the cluster:

  • RAFTADDPEER addr
    Adds a new member to the Raft cluster
  • RAFTREMOVEPEER addr
    Removes an existing member
  • RAFTLEADER
    Returns the Raft leader, if known
  • RAFTSNAPSHOT
    Triggers a snapshot operation
  • RAFTSTATE
    Returns the state of the node
  • RAFTSTATS
    Returns information and statistics for the node and cluster

Read Consistency

The --consistency param has the following options:

  • low - all nodes accept reads, small risk of stale data
  • medium - only the leader accepts reads, itty-bitty risk of stale data during a leadership change
  • high - only the leader accepts reads, the raft log index is incremented to guaranteeing no stale data

For example, setting the following options:

$ redraft --consistency high

Provides the highest level of consistency.

Leadership Changes

In a Raft cluster only the leader can apply commands. If a command is attempted on a follower you will be presented with the response:

SET x y
-TRY 127.0.0.1:7481

This means you should try the same command at the specified address.

Contact

Josh Baker @tidwall

License

RedRaft source code is available under the MIT License.

redraft's People

Contributors

briandowns avatar tidwall avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.