jplana / python-etcd

A python client for etcd
Other
522 stars 210 forks source link

how to watch 1000 keys? #199

Closed humingcheng closed 8 years ago

humingcheng commented 8 years ago

There is an application need to do this work. I can register 1000 watchers with a zookeeperClient to realize that function,but how can I do that with a python-etcd-client? It is a good idea to watch the root key and use "recursive=true", but sometimes the application must watch every key independently. How should I do?

durzo commented 8 years ago

we watch the root with recursive=true and then iterate over each change and perform different actions based on the 2nd level key. with this method we are able to watch over 70,000 keys with ms response times.

humingcheng commented 8 years ago

@durzo Thank you very much! But I still don't now how to watch 5 keys? It must be wasteful to watch the root key for 5 target keys.

lavagetto commented 8 years ago

@humingcheng this is a problem we can't really resolve as etcd responds to single commands only in version 2;

What you could do is to wrap python-etcd into a async loop like gevent and add greenlets that watch the individual keys.