3rd-Eden / node-hashring

hashring is a consistent hashing algorithm for Node.js that is compatible with libketama and python's hash_ring package
MIT License
350 stars 57 forks source link

Saving/Restoring the Hash Ring #40

Closed gavinmcnair closed 8 years ago

gavinmcnair commented 8 years ago

Is there some way to save/reload the initialised hash rings.

I have an implementation which creates the hash rings in the same way each time which takes a second or two per hash ring. If i could dump the created ring (and store it in something like Redis) and load it again when required it would make it much more useful.

3rd-Eden commented 8 years ago

Why would it be more useful? Keys are always hashed the same way. That's the consistent part of the hashring. So loading and saving makes no sense except to save some CPU cycles.

On Sunday, December 6, 2015 at 10:57 PM, gavinmcnair wrote:

Is there some way to save/reload the initialised hash rings. I have an implementation which creates the hash rings in the same way each time which takes a second or two per hash ring. If i could dump the created ring (and store it in something like Redis) and load it again when required it would make it much more useful.

— Reply to this email directly or view it on GitHub (https://github.com/3rd-Eden/node-hashring/issues/40).

gavinmcnair commented 8 years ago

Because I'm using the hash rings for ab testing and i have hundreds of hash rings each for a different ab test after restarting the server each time someone visits each variety of abtest for the first time i have to initialise the associated ring (or spend ages pre-initialising them). Once they are loaded its no bother but on restarting i get about lots of blocking while loading the rings. If i could serialise them i could preload them all. If i scaled to 4000,5000 tests it would block the server for a long time. Unless you can think of a better way :)

gavinmcnair commented 8 years ago

Found better deterministic method for ab testing. This is no longer an issue