{"id":21397397,"url":"https://github.com/silviucpp/eredis_pool","last_synced_at":"2025-07-06T22:08:41.080Z","repository":{"id":83955849,"uuid":"190371591","full_name":"silviucpp/eredis_pool","owner":"silviucpp","description":"Erlang pool for Redis with consistent hashing support","archived":false,"fork":false,"pushed_at":"2025-03-04T14:49:10.000Z","size":43,"stargazers_count":12,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-07T17:41:17.392Z","etag":null,"topics":["consistent-hashing","erlang","keydb","pool","redis"],"latest_commit_sha":null,"homepage":null,"language":"Erlang","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/silviucpp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2019-06-05T10:03:20.000Z","updated_at":"2025-03-04T14:48:59.000Z","dependencies_parsed_at":"2024-01-29T16:41:52.319Z","dependency_job_id":"d2cee26e-668d-454e-bc48-e599511af703","html_url":"https://github.com/silviucpp/eredis_pool","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/silviucpp/eredis_pool","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silviucpp%2Feredis_pool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silviucpp%2Feredis_pool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silviucpp%2Feredis_pool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silviucpp%2Feredis_pool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/silviucpp","download_url":"https://codeload.github.com/silviucpp/eredis_pool/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silviucpp%2Feredis_pool/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263980180,"owners_count":23538922,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["consistent-hashing","erlang","keydb","pool","redis"],"created_at":"2024-11-22T14:42:22.429Z","updated_at":"2025-07-06T22:08:41.074Z","avatar_url":"https://github.com/silviucpp.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"eredis_pool\n=======\n\n[![Build Status](https://app.travis-ci.com/silviucpp/eredis_pool.svg?branch=master)](https://travis-ci.com/github/silviucpp/eredis_pool)\n[![GitHub](https://img.shields.io/github/license/silviucpp/eredis_pool)](https://github.com/silviucpp/eredis_pool/blob/master/LICENSE)\n\nAn Erlang pool for Redis with consistent hashing based on [erlpool][2] and [eredis][3]. \nThis project was developed to be used with [KeyDB][1] by using Active Replication and Multi-Master features, but can be used as well with Redis.  \n\nFeatures\n---------\n\n- Connection pool with persistent connections - this helps reduce connection churn on the Redis server with client connection reuse.\n- Consistent hashing based on `Jump Consistent Hash algorithm` developed by Google\n- Use murmur2 as hashing algorithm\n- Failover over multiple nodes in the same shard (useful when using [KeyDb][1] in `active-active` replication and `multi-master` mode)\n\nKey distribution\n----------------\n\nKeys are hashed using `murmur2` and distributed using the `Jump Consistent Hash algorithm` across the shards. In case a shard has multiple nodes,\nwe send the command first to the node with index `Hash rem length(NodesTags)`. In case that node is down the other nodes in the shard\nare tried till one is up or no other nodes remaining. \n\nQuick start\n------------\n\nCompile:\n\n```\nrebar3 compile\n```\n\nYou need to define your pools inside `app.config` :\n\n```erlang\n{eredis_pool, [\n    {pools, [\n        {pool1, [\n            {shards, [\n                \u003c\u003c\"shard01node01.bucharest.nbz:6379,shard01node02.bucharest.nbz:6379\"\u003e\u003e,\n                \u003c\u003c\"shard02node01.bucharest.nbz:6379,shard02node02.bucharest.nbz:6379\"\u003e\u003e,\n                \u003c\u003c\"shard03node01.bucharest.nbz:6379,shard03node02.bucharest.nbz:6379\"\u003e\u003e,\n            ]},\n\n            {connections_per_host, 5},\n            {connection_options, [\n                {database, 0},\n                {reconnect_sleep, 1000}\n            ]}\n        ]}\n    ]}\n]}.\n```\n\nThe shards are specified using the `host:port` format. In the sam shard multiple nodes are accepted separated by comma.\nFor example in case you are using [KeyDb][1] in `active-active` replication and `multi-master` mode this it's very utils.\nIn case one replica is down the client will discuss with the next one available.\n\nThe supported options for a pool are:\n\n- `database` : database number (integer, default to `0`)\n- `password` : database password (string, default empty password)\n- `reconnect_sleep`: in case connection to server is lost after how many milliseconds should try to reconnect (integer, default to `100`)\n- `connect_timeout`: how many milliseconds will stay in connect until timeout (integer, default `5000`)\n- `socket_options`: list of socket options sent to `gen_tcp`.\n\nExecuting a query:\n\n```erl\n{ok, \u003c\u003c\"OK\"\u003e\u003e} = eredis_pool:q(pool1, [\u003c\u003c\"SET\"\u003e\u003e, Key, Value, \u003c\u003c\"EX\"\u003e\u003e, 10000]).\n```\n\nLimitations\n-----------\n\nPipelines and transactions will work properly only in case they key's inside them goes on the same node. The app will get\nthe key from the first command and sends the pipeline/transaction there.\n\nPerformance testing\n-----------\n\nThe code is in `test` folder. In the following test I send 600000 requests from 600 concurrent processes. Each host having 3 connections.\n\n```\nmake bench\n### run test -\u003e  concurrent clients: 600 requests per client: 1000 \n### 2241 ms 333333 req/sec \n```\n\nYou can run it yourself using `make bench` after you copy the `load_test.erl` from benchmark folder in src and compile.\n\n[1]:https://github.com/JohnSully/KeyDB\n[2]:https://github.com/silviucpp/erlpool\n[3]:https://github.com/wooga/eredis\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilviucpp%2Feredis_pool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsilviucpp%2Feredis_pool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilviucpp%2Feredis_pool/lists"}