{"id":13546397,"url":"https://github.com/RJ/ketama","last_synced_at":"2025-04-02T18:30:41.067Z","repository":{"id":607401,"uuid":"244427","full_name":"RJ/ketama","owner":"RJ","description":"C library for consistent hashing, and langauge bindings","archived":false,"fork":false,"pushed_at":"2020-12-12T06:12:37.000Z","size":337,"stargazers_count":953,"open_issues_count":8,"forks_count":167,"subscribers_count":43,"default_branch":"master","last_synced_at":"2025-04-01T10:07:35.789Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://www.metabrew.com/article/libketama-consistent-hashing-algo-memcached-clients","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RJ.png","metadata":{"files":{"readme":"README","changelog":"CHANGES","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-07-06T16:49:50.000Z","updated_at":"2025-03-31T04:07:01.000Z","dependencies_parsed_at":"2022-08-16T10:31:15.239Z","dependency_job_id":null,"html_url":"https://github.com/RJ/ketama","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RJ%2Fketama","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RJ%2Fketama/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RJ%2Fketama/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RJ%2Fketama/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RJ","download_url":"https://codeload.github.com/RJ/ketama/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246869634,"owners_count":20847166,"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":[],"created_at":"2024-08-01T12:00:36.529Z","updated_at":"2025-04-02T18:30:41.034Z","avatar_url":"https://github.com/RJ.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"***LOOKING FOR NEW MAINTAINER***\n\nI'm not running this anywhere at the moment, and don't have time to work on it.\nI understand libketama and various ports/clients are in production in various places.\nIf anyone is working on this and feels like maintaining, I will give you push/commit access.\nfind me: rj@metabrew.com or twitter.com/metabrew or RJ2 on freenode\n\n\nAbout Ketama\n============\n\nWe wrote ketama to replace how our memcached clients mapped keys to servers.\nPreviously, clients mapped keys-\u003eservers like this:\n\n\tserver = serverlist[hash(key)%serverlist.length];\n\nThis meant that whenever we added or removed servers from the pool, everything\nhashed to different servers, which effectively wiped the entire cache.\n\nKetama solves this problem in the following way:\n\n * Take your list of servers (eg: 1.2.3.4:11211, 5.6.7.8:11211, 9.8.7.6:11211)\n * Hash each server string to several (100-200) unsigned ints\n * Conceptually, these numbers are placed on a circle called the continuum.\n   (imagine a clock face that goes from 0 to 2^32)\n * Each number links to the server it was hashed from, so servers appear\n   at several points on the continuum, by each of the numbers they hashed to.\n * To map a key-\u003eserver, hash your key to a single unsigned int, and find the\n   next biggest number on the continuum. The server linked to that number is\n   the correct server for that key.\n * If you hash your key to a value near 2^32 and there are no points on the\n   continuum greater than your hash, return the first server in the continuum.\n\nIf you then add or remove a server from the list, only a small proportion of\nkeys end up mapping to different servers.\n\nThe server file looks like this:\n1.2.3.4:11211\t900\n5.6.7.8:11211\t300\n9.8.7.6:11211\t1500\n\nip:port and weighting, \\t separated, \\n line endings.\nJust use the number of megs allocated to the server as the weight.\nThe weightings are realised by adding more or less points to the continuum.\n\n\nImplementation\n==============\n\nIncluded in this tarball:\n\t* libketama\n\t* php_ketama\n\t* java_ketama\n\t* python_ketama\n\n\nlibketama is a general purpose C library that maps keys to a list of servers.\nThe server list is read from a file, and the continuum is created and stored\nin shared memory for future access. If the file modification time changes,\nthe continuum is regenerated and shared memory is updated.\n\nphp_ketama is a PHP extenstion that wraps libketama. We use this in our PHP\nmemcached client library.\n\njava_ketama implements the same logic in pure Java, and has been fitted into our\nJava memcached client library.\n\npython_ketama is a python module (with libketama dependencies) contributed by ludvig@blogg.se.\n\nInstallation\n============\n\n* libketama (the general purpose C library)\n\n$ cd libketama\n$ make\n$ make test\n$ su -c \"make install\"\n\nThis will compile libketama and install it to the default prefix /usr/local.\nYou can change the prefix by editing the PREFIX variable in 'Makefile'.\n\n* php_ketama (PHP extension that wraps libketama and therefore depends on it)\n\n$ cd php-4.4.x/ext\n$ ln -s /your/ketama/php_ketama ketama\n$ cd ..\n$ rm -Rf autom4te.cache\n$ ./buildconf --force\n$ ./configure --all_your_configure_options --with-ketama[=/your/ketama/prefix]\n$ make\n$ su -c \"make install\"\n\n* python_ketama (python module that depends on libketama)\n\n$ cd python_ketama\n$ python setup.py build\n$ sudo python setup.py install\n$ python tests.py\n\n* erlang\n\nUse the NIF written at rd.io: https://github.com/abs/ketama/tree/rdio/erlang\n\nDon't forget you might have to restart your httpd!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRJ%2Fketama","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRJ%2Fketama","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRJ%2Fketama/lists"}