-2

Is it possible to have a multi-master redis setup running behind a haproxy / nutcracker?

I want to achieved that wherever the proxy throws the request, they can do both read and write.

Any help will be much appreciated.

HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
Sympatiko
  • 21
  • 4

1 Answers1

0

It's not possible in terms of Redis master/slave. Redis support replication from master to N slaves. One slave server support just one master server. But in haproxy you can configure TCP proxy to any count of Redis nodes to achieve parallel command processing.

Nick Bondarenko
  • 6,211
  • 4
  • 35
  • 56
  • Anyway to route only read traffic to slave redis via haproxy? – Sympatiko Dec 16 '15 at 02:36
  • No, via haproxy you can't do that. You can do something like mirror masters there read/write is same. If you need read - just use one master and N slave servers. – Nick Bondarenko Dec 16 '15 at 04:39
  • Does haproxy will only forward all the request to master? my haproxy backend config would be: backend bk_redis server redis1_master 10.0.0.1:6379 check inter 5s server redis2_slave 10.0.0.2:6379 check inter 5s server redis3_slave 10.0.0.3:6379 check inter 5s What if traffic needs a write? And haproxy forwarded it to redis2 and redis3. Can you suggest some better recommendation. Thanks – Sympatiko Dec 16 '15 at 06:18
  • What does you mean about "only forward"? Your haproxy backend (or other such tools like in mirroring question http://stackoverflow.com/questions/7247668/duplicate-tcp-traffic-with-a-proxy) just open connection and pass all requests to Redis backend. Based on what you ask, you probably just need to setup Redis cluster and cease to suffer. You will have automatic load balancing and fault tolerance. – Nick Bondarenko Dec 16 '15 at 07:12
  • On a single frontend config in haproxy, I want to achieve that every traffic will be load balance to my master and slaves. But what if the traffic is "write" , haproxy is just forwarding any request to it's backend pool right? So what if in the pool there's the slave servers, will the request fail? or it will route to the masters ip? – Sympatiko Dec 16 '15 at 08:11
  • All write trafic should (and would) be transfered from master to slave with Redis replication. You do not need to do this in some other way. All read trafic may be distributed evenly between master and all slave server (or just slave servers - as you want). The last behaviour can be achieved only with application level logic. Somethink like - if this is read query - execute them on read connection, if write query - execute them on write connection. You can't achieve this behaviour with haproxy or any other proxy server. – Nick Bondarenko Dec 16 '15 at 08:17
  • Thanks for enlightening me! – Sympatiko Dec 17 '15 at 02:18
  • http://stackoverflow.com/questions/41500391/redis-cluster-load-balancing – user3123372 Jan 06 '17 at 06:46