El Guapo
El Guapo

Reputation: 5781

Using Spring Cloud to implement a Global Lock

I have a requirement to implement a sequence generating service such that it runs multiple instances of this service in n number of data centers (vm or baremetal machines). The following are the rules for the service regardless of which instance of the service is called (from any of the data centers):

I've thought about a lot of different solutions, but basically it comes down to some sort of distributed service locking. Spring cloud claims to have some sort of "global lock", however, I don't see any real description or implementation example. I am open to any other solution (except Apache Zookeeper).

I toyed with the idea of running each service behind RabbitMQ and letting each service notify the others when one is running, but that doesn't seem very efficient.

Upvotes: 3

Views: 6499

Answers (2)

spencergibb
spencergibb

Reputation: 25157

We haven't released anything yet, but you can follow the progress of https://github.com/spring-cloud/spring-cloud-cluster which has the concept of locks implemented with various technologies.

Upvotes: 2

joshuad2
joshuad2

Reputation: 317

Take a look at Consul it's a lightweight distributed locking mechanism that can be used to expose a service across a network like you describe. You will still need to implement a way to increment the sequence but Consul can be used to hold the value and implement the lock.

Upvotes: 3

Related Questions