pythonamazon-ec2apache-zookeeperkazoo

How to keep kazoo connected to zookeeper?


I am trying to use Zookeeper to manager distributed cluster in sync.

Right now I am using ec2 spot instances and I want each ec2 spot instance to connect & create znode on zookeeper with some metadata like instance id, private hostname, instance type.

So far I am manage to make each spot instance to create znode on zookeeper with respective metadata. but I want to make it such a way that when the instance(spot instance) is taken away then that znode to be disappear itself.

Or is there any better way to do this ?


Solution

  • use the ephemeral nodes of zookeeper. For kazzoo just use the create with the ephemeral parameter set:

    client.create(path, ephemeral=True)
    

    But keep in mind, that you can't create nodes underneath a ephemeral node.