如何实现分布式信号量?

时间:2023-01-25 18:05:54

I have a limited set of resources that I want to share between multiple processes than run on multiple servers. I guess what I need could be called a distributed semaphore.

我有一组有限的资源,我希望在多个进程之间共享,而不是在多个服务器上运行。我猜我需要的东西可以称为分布式信号量。

I have found an old Perl implementation (based on memcached) that could be adapted. I have not fully investigated it yet.

我找到了一个可以调整的旧Perl实现(基于memcached)。我还没有完全调查过它。

Is there a library/component/software that already does that? An algorithm, perhaps? How about failover?

是否有库/组件/软件已经这样做了?也许算法?故障转移怎么样?

3 个解决方案

#1


7  

The algorithm for this is called Paxos. There are other algorithms, but they all reduce down to Paxos (or are incorrect). The most popular implementation of it is Apache Zookeeper. The Zookeeper servers run Paxos amongst themselves. Clients refer to named objects and can lock them etc.

这个算法称为Paxos。还有其他算法,但它们都减少到Paxos(或不正确)。它最流行的实现是Apache Zookeeper。 Zookeeper服务器之间运行Paxos。客户端引用命名对象并可以锁定它们等。

#2


1  

In order to implement a distributed semaphore, you need to define an authority amongst a cluster of node, then once it is selected, you need to centralize requests to it. Handling lock requests is a piece of cake, selecting the leader is more complicated.

为了实现分布式信号量,您需要在节点集群中定义权限,然后一旦选择它,您需要将请求集中到它。处理锁定请求是小菜一碟,选择领导者更复杂。

Paxos will solve that for you. I have just updated the wikipedia page, because the algorithm description was incomplete and misleading.

Paxos将为您解决这个问题。我刚刚更新了*页面,因为算法描述不完整且具有误导性。

#3


0  

there is a simpler algorithm similar to paxos, it's called raft: http://raftconsensus.github.io/

有一种类似于paxos的简单算法,它叫做筏:http://raftconsensus.github.io/

#1


7  

The algorithm for this is called Paxos. There are other algorithms, but they all reduce down to Paxos (or are incorrect). The most popular implementation of it is Apache Zookeeper. The Zookeeper servers run Paxos amongst themselves. Clients refer to named objects and can lock them etc.

这个算法称为Paxos。还有其他算法,但它们都减少到Paxos(或不正确)。它最流行的实现是Apache Zookeeper。 Zookeeper服务器之间运行Paxos。客户端引用命名对象并可以锁定它们等。

#2


1  

In order to implement a distributed semaphore, you need to define an authority amongst a cluster of node, then once it is selected, you need to centralize requests to it. Handling lock requests is a piece of cake, selecting the leader is more complicated.

为了实现分布式信号量,您需要在节点集群中定义权限,然后一旦选择它,您需要将请求集中到它。处理锁定请求是小菜一碟,选择领导者更复杂。

Paxos will solve that for you. I have just updated the wikipedia page, because the algorithm description was incomplete and misleading.

Paxos将为您解决这个问题。我刚刚更新了*页面,因为算法描述不完整且具有误导性。

#3


0  

there is a simpler algorithm similar to paxos, it's called raft: http://raftconsensus.github.io/

有一种类似于paxos的简单算法,它叫做筏:http://raftconsensus.github.io/