How to design a highly available script ?

  1. Eliminate a single point of failure. The systems should be made highly available by adding redundancy.
  2. Automated failover & failback on an event of unplanned/planned failure.

Requirement:

  1. I need my script to run only on one application server at a time.
  2. I need my script to automatically failover to secondary server if primary server is down.
  3. I need my script to failback or run from primary server if primary server is up.
  1. Use a configurable attribute to indicate the application type of server. It should simply say whether this the designated primary instance or a backup secondary. For example server_roleattribute is defined with possible values primary & secondary .The attribute can be defined as a command line argument or config file.
  2. Evaluate the server_role,if it’s primary we just need to focus on execution of whatever business logic we have.
  3. If the serverType is secondary ,we simply check primary is still up & running. This can be done by using basic Linux ping command.
  4. If primary is up and running, we simply checks if the cronjob is not commented. If it’s present, let’s trust Linux services to execute the job at right time.
  5. If we couldn’t ping primary for some reason, the secondary script need to take up the responsibility and execute the business logics.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store