Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi Master setup #30

Open
Cediddi opened this issue Aug 10, 2018 · 2 comments
Open

Multi Master setup #30

Cediddi opened this issue Aug 10, 2018 · 2 comments

Comments

@Cediddi
Copy link

Cediddi commented Aug 10, 2018

Hi, I want to use sherlock in a distributed system. I'd like to have multi master setup because if lock server (memcached, redis, etcd) goes down, all system goes down. How can we solve that?

@vaidik
Copy link
Collaborator

vaidik commented May 11, 2019

Hi @Cediddi,

This is very much possible with sherlock even now.

If you are using Redis, you can't do Redis clustering because sherlock uses redis-py and redis-py does not support clustering. However it supports sentinel. You can read this article which explains how to setup Redis Sentinel and this article to understand how to use redis-py to discover masters and slaves using sentinel. Since Sherlock uses redis-py internally, it would support using sentinel as well. This example should work (although I haven't tested it myself):

import redis
import sherlock

from redis.sentinel import Sentinel

sentinel = Sentinel([('X.X.X.X', 26379)], socket_timeout=0.1)
master_client = sentinel.master_for('mymaster', socket_timeout=0.1)

sherlock.configure(client=master_client)

lock = sherlock.Lock('my_lock')
lock.acquire()

Etcd also has a cluster guide to help you achieve the same. In a very similar way, you can achieve this with etcd as well if you have etcd in a cluster mode.

import etcd
import sherlock

etcd_client = etcd.Client(host=(('X.X.X.A', 4001), ('X.X.X.B', 4001), ('X.X.X.C', 4001)))

sherlock.configure(client=etcd_client)

lock = sherlock.Lock('my_lock')
lock.acquire()

@vaidik
Copy link
Collaborator

vaidik commented May 11, 2019

Memcached doesn't have a very straight forward way to achieve reliability like Redis and Etcd. You can read more about how Memcached works and what most people do here and here.

My recommendation would be to stick with either Redis or Etcd. But I don't know your requirements well enough. If you could share your use-case, I might be in a better position to comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants