josevalim

josevalim

Creator of Elixir

Proposing Registry

Hello everyone,

I would like to propose the addition of the Registry project to Elixir:

The Registry project is a local and scalable key-value process storage in Elixir. It encapsulates 3 known use cases:

  • Process registry: to register process with dynamic names. Often Elixir developers need to rely on gproc or other tools.
  • Code dispatching: dispatch a module/function associated to a given key
  • PubSub implementation: send messages to local processes registered under a given topic

There are probably other use cases waiting to be discovered. :slight_smile:
You can learn more in the documentation:

http://elixir-lang.org/docs/registry/

The project clocks only 700LOC with documentation and performs well. We have extracted, improved and generalized the patterns from Phoenix.PubSub, the implementation used to manage and publish messages to 2 million subscribers.

When benchmarking thousands of processes registering serially, it is twice slower than local atoms, albeit 33% faster than gproc. On concurrent cases, it distributes well across all cores, becoming only 15% slower than local atoms, and 3x faster than gproc on a machine with two cores (gproc seems to be serial with its default configurations so the difference will be even bigger on more cores).

Please give it a try and let us know what you think.

Most Liked

josevalim

josevalim

Creator of Elixir

The Registry has been merged into Elixir master.

josevalim

josevalim

Creator of Elixir

This is local, the OTP one is distributed. You shouldn’t use the OTP one to store local data, as looking up or storing information may require messages across nodes.

On my benchmarks, the use of partitions have only been justified for the pubsub/dispatch use cases. For the unique registry, I couldn’t find a case yet where increasing the number of partitions matter. However, my current machine has only 2 cores. Maybe a partitioned unique registry may matter on machines with 16+ cores.

:gproc is a great project, albeit I find its API confusing (YMMV). If you asked me about a registry in Elixir six months ago, the answer would likely be no. So what has changed?

  1. I confirmed with the OTP team they have no plans to tackle a local registry
  2. While working on a separate project wth @chrismccord, we realized we could generalize the PubSub implementation while keeping the scalability aspects of Phoenix.PubSub
  3. The generalization of PubSub made it useful for at least 2 other common cases: :via lookups and module/function dispatching. :via lookups is a frequently required feature. Plus I am using module/function dispatching to replace GenEvent in another app and we will explore it instead of GenEvent in Logger too.

Being faster than gproc is a perk, although the registry was designed to scale with multiple cores. Work in the registry is always done on the client, there is no centralized entity, and that’s another useful pattern to have in hand.

In other words, there isn’t a single reason. We found a generic solution that is performant and scalable and our reaction is that it can be very useful as part of the language.

josevalim

josevalim

Creator of Elixir

Its API is quite simpler than gproc’s. There is no support for distribution as well, it is by definition local. One reason why we are hesitant on tackling any distributed registry as part of Elixir is because such is already part of the OTP team plans.

Where Next?

Popular in News Top

Elixir
1. Enhancements Elixir [File] Support distributed File.Stream [Module] Add Module.get_last_attribute/3 [Task] Reduce footprint of tasks ...
New
Elixir
Announcement: https://elixir-lang.org/blog/2026/06/03/elixir-v1-20-0-released/ This release requires Erlang/OTP 27+ and is compatible wi...
New
Elixir
Release: Release v1.12.0-rc.1 · elixir-lang/elixir · GitHub 1. Enhancements Elixir [Code] Add Code.cursor_context/2 to return the conte...
New
josevalim
Hi everyone, The next (and hopefully last) release candidate for Elixir v1.14 is out: Release v1.14.0-rc.1 · elixir-lang/elixir · GitHub...
New
josevalim
Announcement: https://elixir-lang.org/blog/2019/01/14/elixir-v1-8-0-released/ Release notes: https://github.com/elixir-lang/elixir/relea...
New
Elixir
Release: https://github.com/elixir-lang/elixir/releases/tag/v1.9.0 Releases The main feature in Elixir v1.9 is the addition of releases....
New
Elixir
1. Enhancements Elixir [Code] Add :emit_warnings for Code.string_to_quoted/2 [File] Add :offset option to File.stream!/2 [Kernel] Auto i...
New
Elixir
Overall, the compiler finds more bugs, for free, and it has never been faster: Infers types across clauses, finding more bugs and dead...
New
josevalim
Elixir v1.14 brings many improvements to the debugging experience in Elixir and data-type inspection. It also includes a new abstraction...
New
Elixir
Release: https://github.com/elixir-lang/elixir/releases/tag/v1.10.0-rc.0 Support for Erlang/OTP 21+ Elixir v1.10 requires Erlang/OTP 21+...
New

Other popular topics Top

marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
marick
I had some trouble figuring out how to make many-to-many associations work. Once I got it working, I wrote a blog post. Because I'm a nov...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

We're in Beta

About us Mission Statement