Skip to content
This repository has been archived by the owner on Nov 23, 2022. It is now read-only.

barambani/varekai

Repository files navigation

This repository is ⚰️ ARCHIVED ⚰️

The last day of operation was on November 23, 2022


Varekai

Varekai is a coding excercise. The purpose here is to create a different implementation of the RedLock distributed locking algorithm. It is written in C# using Xamarin Studio and is developed on Mono over Mac OS X.

More details about RedLock can be found here. Anyone interested in it or in distributed locking algorithms, might also read this article by Martin Kleppmann on the reasons why RedLock might not be the best choice. Besides, to have a complete view of the discussion, the counter-analysis by Salvatore Sanfilippo gives a second opinion on the subject. Also, this article by Flavio Junqueira describes the same kind of issues in Zookeeper. Further material is offered by this interesting paper about Chubby, a distributed lock service from Google.

Modules

  • Locker: the locking library, it implements the locking algorithm
  • Sample Services: sample Topshelf services that demonstrate the adapter in some use cases
  • Infrastructure Helpers: some helper functions to speed up the services' creation
  • Utility: a set of useful functions

How To Run It

To run Varekai you need access to a number of instances of Redis server. The algorithm is quorum based so, in case of compeeting clients, the lock will be considered held if the write succeedes at least on the half plus one of the Redis servers. This makes possible to have any number (even or uneven) of nodes, even though doesn't make a lot of sense having less than three. If you need info on how to configure Redis the official documentation is a good place to start. As an alternative the docker-compose.yml file might be used to start seven instances of Redis on alpine Linux listening on the ports from 7001 to 7007. To tell to Varekai where it will find the servers you have to edit the file RedisNodes.txt of the HelloWorldService project. The version included in this repository works with the instances created by the docker compose file.

[
	{
		address: 'localhost',
		port: 7001
	},
	{
		address: 'localhost',
		port: 7002
	},
	{
		address: 'localhost',
		port: 7003
	},
	{
		address: 'localhost',
		port: 7004
	},
	{
		address: 'localhost',
		port: 7005
	},
	{
		address: 'localhost',
		port: 7006
	},
	{
		address: 'localhost',
		port: 7007
	}
]

How To Use It

The sample services are only some possible ways to use and experiment Varekai. I plan to add more of them and try to explore different use cases for the RedLock algorithm, but I use my spare time to do it, so I really don't know how much it will be able to proceed. In case you want to play with it, all the dependencies of the Locking Adapter are injected using Autofac so it shouldn't be a problem to start from the Hello World service and implement your own logic over it.

About

C# implementation of the Redlock distributed locking algorithm

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages