There are various techniques for leader-election, (deciding which one of N nodes is the master), one of variations which is getting a lot of buzz at the moment is the Raft algorithm.
Searching CPAN for "leader", "election", and similar I'm seeing no hits. Nor do I see anything in the raft samples list.
If anybody could point me to an existing implementation for automatically electing a master, whether via HTTP, TCP, UDP, or Multicast, I'd be enormously grateful - if not I guess I have the opportunity to submit something to CPAN myself!