when you need to connect a third party service to a database
you would need a service to connect them
problem would arise if this single machine or service fails
solution would be to introduce redundancy, adding multiple servers
a new problem would arise where we do not want to replicate sensitive requests like payments across multiple servers, such requests should only be done once
solution is to use Leader Election
instead of having all servers to do the same thing, via leader election, the servers will elect the leader and only the leader would perform the sensitive request
if anything happens to the leader, a new leader will be elected from the rest of the servers and will take over
the act of all servers to provide consensus to allow a server to become the leader is difficult to implement, which is something you do not do by yourself
the consensus algorithm is used and applied for this case