Giter Club home page Giter Club logo

Comments (4)

colinmollenhour avatar colinmollenhour commented on September 15, 2024

I haven't tried them.. However, not sure if I really want to go that route (building Redis high availability logic into the application or library). I recently started using Sentinel myself and in my setup the HAProxy instances do the health checks against the redis servers, not the sentinels and they require a node to be "role:master". In this way the HAProxy instances will always direct traffic to the master and the clients simply connect directly to HAProxy and do not need to be sentinel-aware. The sentinels can be ignored by the client application entirely, although they are still useful for automating the cluster initialization and failover.

defaults
  mode tcp
  timeout client     1h
  timeout server     1h
  timeout connect 1000

frontend redis-tcp
  bind *:6379
  default_backend redis

# The tcp-check will ensure that only reachable master nodes are considered "up". 
backend redis
  balance first
  option tcplog
  option tcp-check
  tcp-check send info\ replication\r\n
  tcp-check expect string role:master
  default-server inter 5000 downinter 5000 fastinter 1000 rise 2 fall 3 maxconn 256 maxqueue 128
  {{HOSTS}}
  server node${num} ${ip}:6379 check
  {{/HOSTS}}

The {{HOSTS}} part renders one line per server. See https://github.com/colinmollenhour/haproxy-service

from credis.

tegansnyder avatar tegansnyder commented on September 15, 2024

Hi @colinmollenhour,

Thanks for your reply. I'm trying to understand your configuration. It appears you are instructing HAProxy to do health-checks against the Redis master servers.

I have a similar HAProxy configuration, it looks as follows:

defaults
    mode tcp
    timeout connect 4s
    timeout server  30s
    timeout client  30s

frontend redis-tcp
    bind *:26379 name redis
    default_backend redis-alpha

backend redis
    option tcp-check
    tcp-check send AUTH\ OMMITED_REDIS_PWD\r\n
    tcp-check send PING\r\n
    tcp-check expect string +PONG
    tcp-check send info\ replication\r\n
    tcp-check expect string role:master
    tcp-check send QUIT\r\n
    tcp-check expect string +OK
    server redis-1 X.X.X.1:6379 maxconn 1024 check inter 1s
    server redis-2 X.X.X.2:6379 maxconn 1024 check inter 1s
    server redis-3 X.X.X.3:6379 maxconn 1024 check inter 1s
    server redis-4 X.X.X.4:6379 maxconn 1024 check inter 1s
    server redis-5 X.X.X.5:6379 maxconn 1024 check inter 1s

After reading your reply, I'm trying to understand if your configuration allow slaves? The ideal scenario would be to utilize the slaves for high availability/load balancing and the master for writes. When health check fails on a master a new master is promoted.

Can you share an example your sentinel.conf?

Thanks!

from credis.

colinmollenhour avatar colinmollenhour commented on September 15, 2024

My HAProxy does health checks against all redis nodes, but not redis sentinels. It only considers the master node to be up and considers all others to be down. I'm only going for redundancy but if you wanted to also go for load balancing reads I would recommend having two HAProxy backends, one for writes (only the master is up) and one for reads (all nodes that are part of the replication).

from credis.

tegansnyder avatar tegansnyder commented on September 15, 2024

Good call on two backends, that is going to be what I do. Thanks Colin, much appreciated.

from credis.

Related Issues (20)

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.