RubyFlow The Ruby and Rails community linklog


The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

[gem] Redis-based distributed locks with "acquisition queue" capabilities

New gem ( [RedisQueuedLocks] that provides distributed redis-based locks with "lock acquisition" ordered queue capabilites and depends on pre-configured RedisClient istance (Reidis infrastracture layer you should provide by yourself)

The main feature:

Each lock request is put into the request queue (each lock is hosted by it’s own queue separately from other queues) and processed in order of their priority (FIFO). Each lock request lives some period of time (RTTL) (with re-queue capabilities) which guarantees the request queue will never be stacked.

This feature also allowed us to replace PostgreSQL's "advisory locks", cuz we uses them ultra very oftenly for some cases of logic: postgresql's advosiry locks works in "ordered queue" manner, and it is very necessary for us to save this behavior in Redis-Queued-Locks (in my company). The main logic is based on the Redis'es SortedSets under the hood and working with this functionality. It works very fast and stable.

It is still in development phase, but all major features are ready, we are using it in production already, and "1.0.0" release is coming really really soon :)

Battle-tested on the huge projects in the real production under high-load (thousand locks are acquired and released every second in our applications).

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in