{"id":13504418,"url":"https://github.com/discord/ex_hash_ring","last_synced_at":"2026-04-04T02:01:20.869Z","repository":{"id":39453844,"uuid":"82606637","full_name":"discord/ex_hash_ring","owner":"discord","description":"A fast consistent hash ring implementation in Elixir.","archived":false,"fork":false,"pushed_at":"2025-04-03T19:59:54.000Z","size":122,"stargazers_count":566,"open_issues_count":0,"forks_count":25,"subscribers_count":180,"default_branch":"master","last_synced_at":"2026-03-27T18:10:41.564Z","etag":null,"topics":["distributed-systems","elixir","erlang","hashring"],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/discord.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-02-20T21:54:44.000Z","updated_at":"2026-03-26T13:55:06.000Z","dependencies_parsed_at":"2022-09-20T03:04:04.595Z","dependency_job_id":"deec8a69-ba09-414a-963f-e5ef78e57078","html_url":"https://github.com/discord/ex_hash_ring","commit_stats":null,"previous_names":["discordapp/ex_hash_ring"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/discord/ex_hash_ring","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discord%2Fex_hash_ring","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discord%2Fex_hash_ring/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discord%2Fex_hash_ring/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discord%2Fex_hash_ring/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/discord","download_url":"https://codeload.github.com/discord/ex_hash_ring/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discord%2Fex_hash_ring/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31384847,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T01:22:39.193Z","status":"online","status_checked_at":"2026-04-04T02:00:07.569Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["distributed-systems","elixir","erlang","hashring"],"created_at":"2024-08-01T00:00:37.320Z","updated_at":"2026-04-04T02:01:20.808Z","avatar_url":"https://github.com/discord.png","language":"Elixir","funding_links":[],"categories":["Components"],"sub_categories":["Vectors"],"readme":"# ExHashRing\n\n[![CI](https://github.com/discord/ex_hash_ring/workflows/CI/badge.svg)](https://github.com/discord/ex_hash_ring/actions)\n[![Hex.pm Version](http://img.shields.io/hexpm/v/ex_hash_ring.svg?style=flat)](https://hex.pm/packages/ex_hash_ring)\n[![Hex.pm License](http://img.shields.io/hexpm/l/ex_hash_ring.svg?style=flat)](https://hex.pm/packages/ex_hash_ring)\n[![HexDocs](https://img.shields.io/badge/HexDocs-Yes-blue)](https://hexdocs.pm/ex_hash_ring)\n\nA pure Elixir consistent hash ring implemention based on the excellent [C hash-ring lib](https://github.com/chrismoos/hash-ring) by [Chris Moos](https://github.com/chrismoos).\n\nExHashRing is a production ready library actively maintained and in use at [Discord](https://discord.com).\n\nExHashRing provides the following features.\n\n- Lookup optimized ring storage. A ring is stored in an [ETS table](https://erlang.org/doc/man/ets.html) which provides excellent lookup performance.\n- Key overrides that allow the client to pin a key to a member.\n- Configurable replica count for virtual nodes.\n- Configurable history that allows for stable lookups over time.\n\n## Installation\n\nAdd it to `mix.exs`.\n\n```elixir\ndefp deps do\n  [{:ex_hash_ring, \"~\u003e 6.0\"}]\nend\n```\n\n## Upgrading to 6.0.0\n\nVersion 6.0.0 introduces a number of breaking changes.  Refer to the [Upgrade Guide](/pages/upgrade.md) for instructions.\n\n## Quickstart\n\nEach Ring is managed by a GenServer, here's an example of starting an empty Ring.\n\n```elixir\niex(1)\u003e alias ExHashRing.Ring\nExHashRing.Ring\niex(2)\u003e {:ok, ring} = Ring.start_link()\n{:ok, #PID\u003c0.166.0\u003e}\n```\n\nWe can add a single node with `add_node/2`\n\n```elixir\niex(3)\u003e Ring.add_node(ring, \"a\")\n{:ok, [{\"a\", 512}]}\n```\n\nThe `512` above is the number of replicas for this node.  Since we did not specify a custom number of replicas, it was added with the default for this Ring, which itself defaults to `512`.  We can control the number of default replicas when we start_link the Ring and we can control the number of replicas on a per-node basis.\n\nWe can add another node with a custom replica count with `add_node/3`\n\n```elixir\niex(4)\u003e Ring.add_node(ring, \"b\", 100)\n{:ok, [{\"b\", 100}, {\"a\", 512}]}\n```\n\nNow that we have some nodes we can use our Ring to map keys to nodes with the `find_node/2` function.\n\n```elixir\niex(5)\u003e Ring.find_node(ring, \"key1\")\n{:ok, \"a\"}\niex(6)\u003e Ring.find_node(ring, \"key37\")\n{:ok, \"b\"}\n```\n\n## Documentation\n\nThe Quickstart above just scratches the surface of the functionality that ExHashRing provides.  For more details see the [HexDocs](https://hexdocs.pm/ex_hash_ring)\n\n## Configuration\n\nExHashRing exposes some configuration options under the `:ex_hash_ring` key.\n\n| Key         | Description                                                                              | Default |\n|-------------|------------------------------------------------------------------------------------------|---------|\n| `:depth`    | Default history depth for new rings                                                      | 1       |\n| `:gc_delay` | The amount of time, in milliseconds, to wait before garbage collecting stale generations | 10_000  |\n| `:replicas` | Default replicas setting for new rings                                                   | 512     |\n\n## License\n\nHash Ring is released under [the MIT License](LICENSE). Check [LICENSE](LICENSE) file for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiscord%2Fex_hash_ring","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiscord%2Fex_hash_ring","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiscord%2Fex_hash_ring/lists"}