For microservice HA, I know there's the "Active/Active" configuration as well as the "Active/Standby" configuration.
I'm wondering if you might use Leader Election for something in the middle. For example, say there are 3 microservices which all share the load of processing messages off a bus and storing them in a database. But only one of them is needed to do daily database purging. Might you use leader election to determine which one should do that task?
Or is that always a bad design and should you use a separate application for that instead?
In distributed systems where multiple nodes are running identically then we are calling this environment as leaderless. As the name suggests there no leader to follow. Each node can perform the same set of operations.
If there is/are special operation(s) which needs to be run on a single node then have multiple options:
Let's examine the first option. How can you guarantee that only one node can execute the operation?
*Leader election is a specialised consensus protocol
Leader election is a complex problem, because you have to solve a lots of problems like:
These questions are more or less solved in Paxos, Raft and ZAB protocols.
I'm not saying that leader election is a bad idea here, but it is certainly makes your system more complex. And it is hard to implement it in a correct way.
I also want to emphasize that LE shines in those use cases where you have a complex flow/logic where you need to have a coordinator (like data replication).