mailgun / groupcache

Clone of golang/groupcache with TTL and Item Removal support
Apache License 2.0
495 stars 73 forks source link

What should we do when membership changes ? #28

Closed haifeiWu closed 3 years ago

haifeiWu commented 3 years ago

When a new server joins or goes offline,how groupcache solve this problem

thrawn01 commented 3 years ago

This question has been asked enough, that I'll document something more concrete once https://github.com/mailgun/holster/pull/77 which includes a discovery package used to monitor peers.

To answer your question you must use an external system like kubernetes or nomad/consul to know when a node comes up or goes down. There is some existing code in https://github.com/mailgun/gubernator/blob/master/daemon.go#L154-L183 that should give you a starting point. You just have to call pool.Set() when the kubernetes, nomad, memberlist notifies you when the nodes have changed.

I hope this gives you some insight.

haifeiWu commented 3 years ago

got it thank you