Git Product home page Git Product logo

redisha's Introduction

redisHA

Solution of redis failover, read/write separation, and read load-balance. Total client-independent

What can it do

  • Let your redis master/slave failover automatically
  • Switch clients to the new master when failover happens
  • read/write separation
  • Read traffic load-balance (among slaves or all servers)
  • No multi-master problem (compare to legacy HAProxy redis check)
  • Total client-independent, doesn't require any client libraries

Prerequisite

  • Redis
  • HAProxy (community edition is enough)

How to use

Depoly a 3-server redis enviorment (1 master, 2 slaves)

For this part, you can find further instructions at https://redis.io/topics/replication

Deploy 3 sentinels

  1. Make 3 copies of sentinel.conf. Modify them, replace properties surrounded by angle brackets with real ones.
  2. Start 3 sentinels
redis-sentinel ./sentinel.conf

Run HAProxy

  1. Modify haproxy.cfg, replace properties surrounded by angle brackets with real ones, and make changes accord to comments if needed.
  2. Start HAProxy
haproxy -f ./haproxy.cfg

Then it's done

just let your clients use HAProxy's 16379 port for writes and 16479 port for reads

How to test failover

Connect to current master, execute command:

DEBUG sleep 10

the failover should happen after 8 secs, then you can visit http://:8888/haproxy?stats to see if HAProxy's stat changes

More to do

Make your HAProxy able to failover (keepalived recommended)

redisha's People

Contributors

kelgon avatar

Watchers

James Cloos avatar  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.