(I will try to keep this question as short as possible, clearly describing the situation. Please comment if something is missing.)
Situation
- I am running a cluster with three servers in the same data center
- Each server runs exactly the same application code to facilitate deployment.
goal
- Perform one task (call it Task X) every minute on the same server.
In these conditions
- The cluster remains distributed and available.
- Each server runs the same application code. In other words, there is no such thing as "deploy code A to the main server and deploy code B to all secondary servers.
The reason I don’t want to distinguish between the type of server is to maintain high availability (to avoid problems when the so-called master happens), redundancy (to distribute the load) and to avoid creating a complex deployment procedure where I need to deploy various applications on different servers.
Why is it so hard? If I were to add code that would perform this task every 5 minutes, then each server would execute it, because each server would execute the same application code. Thus, they should be able to coordinate which server will work the same during each tick.
I can use distributed messaging engines like Apache Kafka or Redis . If we use such a mechanism to coordinate such a task, how would such an “algorithm” work?
I asked this question to someone else, his answer was to use a task queue. However, this does not seem to solve the problem, because the question remains: which server is going to add the task to the task queue? If all servers add the task to the queue, this will result in duplicate entries. Also, which server will perform the next task in the queue? All this must be solved by coordination within the cluster without differentiating between different types of servers.
source share