Best way to dynamic add/remove groupcache's peers?

1,022 views
Skip to first unread message

Bert Chang

unread,
Nov 13, 2013, 9:41:56 AM11/13/13
to golan...@googlegroups.com
Hi there,

Use case:
Maybe today I have large amount of requests, and I want to add some peers.

groupcache provides a convenient way to set peers. (that is func (p *HTTPPool) Set(peers ...string))
But I'm wondering: What is the best way to notify the running groupcache's instances that there is a new peer?
Which means I want to be able to dynamic add/remove groupcache's peers.

The solutions come into my mind:
1. create a http api interface. when I run up a new groupcache instance, I send request to the http api. And as soon as the api receive request, it use Set(peers...) to add peers.
2. Set peers address first, i.e. Set("http://localhost:50000", ... ,"http://localhost:599999"). Then if I want to run up a new groupcache instance, I just need to run the instance in this port range.

Is there any better solution?
Thanks!

Fatih Arslan

unread,
Nov 13, 2013, 12:16:40 PM11/13/13
to Bert Chang, golan...@googlegroups.com
Hey,

What you need is a service discovery application that you use for your
services. You have to register each of your service (when they start
they will make a request to this app) and then whenever a new service
is registered you just notify the others. There are many tools to
build to make service-discovery easy. Some of them (written in Go):

etcd: https://github.com/coreos/etcd
serf: https://github.com/hashicorp/serf
doozer: https://github.com/ha/doozerd

there is also Apache's Zookeper which is very complex.
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.



--
Fatih Arslan

Fatih Arslan

unread,
Nov 13, 2013, 12:18:42 PM11/13/13
to Bert Chang, golan...@googlegroups.com
There is also skydns, I forgot it:

skydns: https://github.com/skynetservices/skydns
--
Fatih Arslan

atomly

unread,
Nov 13, 2013, 1:37:09 PM11/13/13
to Fatih Arslan, Bert Chang, golang-nuts

On Wed, Nov 13, 2013 at 12:16 PM, Fatih Arslan <ftha...@gmail.com> wrote:
there is also Apache's Zookeper which is very complex.

I have to disagree here... Zookeeper is definitely very extensive and can potentially be used to do complex things, but it is built on very simple and sound principles. Things like group membership, which is what is wanted here, are provided out-of-the-box and I have to say work incredibly well with it...

http://zookeeper.apache.org/doc/trunk/recipes.html

:: atomly ::

[ ato...@atomly.com : www.atomly.com  : http://blog.atomly.com/ ...
[ atomiq records : new york city : +1.347.692.8661 ...
[ e-mail atomly-new...@atomly.com for atomly info and updates ...

John Wesonga

unread,
Feb 19, 2014, 5:58:55 AM2/19/14
to golan...@googlegroups.com, Fatih Arslan, Bert Chang
I stumbled upon this interesting post about using Doozer to manage GroupCache peers http://joshua.themarshians.com/doozer-groupcache.html the code is readily available. Personally i tried it out and had issues with Doozer but that's just me....
Reply all
Reply to author
Forward
0 new messages