Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8769979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:28:03+00:00 2026-06-13T17:28:03+00:00

(I shall try to keep this question as short as possible while clearly describing

  • 0

(I shall try to keep this question as short as possible while clearly describing the situation. Please comment if anything is missing.)

The situation

  • I’m running a cluster with three servers in the same datacenter
  • To ease deployment, each server runs exactly the same application code

The objective

  • To run a single task (call it Task X) every minute by a single server.

Under these conditions

  • The cluster remains distributed and highly available
  • Each server keeps running the same application code. In other words there is no such thing as “deploy code A to a master server and deploy code B to all secondary servers.

The reason I do not wish to distinguish between the kind of server is to maintain high availability (avoid problems when a so called master goes down), redundancy (distribute load), and to avoid creating a complex deployment procedure where I need to deploy different applications to different kinds of servers.

Why is this so difficult? If I were to add code that would execute this task every 5 minutes, then each server would execute it because each server runs the same application code. As such they need to be able to coordinate which server is going to run the same during each tick.

I am able to use distributed messaging mechanisms such as Apache Kafka or Redis. If using such mechanism to coordinate such task, how would such “algorithm” work?

I posed this question to someone else, his reply was to use a task queue. However, this does not seem to solve the issue, because the question remains: which server is going to add the task to the task queue? If all servers would add the task to the queue then it would result in duplicate entries. Moreover, which server is going to execute the next task in the queue? All this needs to be decided through coordination within the cluster, without distinguishing between different kinds of servers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:28:04+00:00Added an answer on June 13, 2026 at 5:28 pm

    It sounds like you are looking for a distributed lock. Redis does this wonderfully with setnx. If you combine it with expire then you can create global locks that are released every N Seconds.

    setnx will only write the value and return true if the key does not already exist. Redis operations are atomic so only the first server to call setnx after the key expires will get the go ahead to run the task.

    Here is an example in ruby:

    # Attempt to get the lock for 'Task X' by setting the current server's hostname
    if redis.setnx("lock:task:x", `hostname`.chomp)
      # Got the lock, now I set it to expire after 5 minutes
      redis.expire("lock:task:x", 60 * 5)
      # This server has the go ahead to execute the task
      execute_task_x
    else
      # Failed to get the lock. Another server is doing the work this time around
    end
    

    With this you are still reliant on calling one server Redis Master unless you take advantage of redis-sentinel. Take a look at the redis-sentinel docs for information on how to configure automatic fallover.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I shall try and keep my scenario as brief as possible and to the
Hi I shall try to explain clearly what I need to be able to
Please bear with me for the length of this question, I tried to be
I hope this question is SO worthy, but I'll give it a try... I
I wan't sure how to word this question so I'll try and explain. I
as the title says, I keep getting undefined when I try to get the
G'day, This is related to my question on star developers and to this question
I use External JavaScripts in a website as I always try to keep JavaScript
For some reason, I keep getting this error. Couldn't find Album without an ID
I asked this question about using the system-drawables in an Android-app some time ago:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.