0

I need to poll a database table (DB2) using Python. The table gets updated quite frequently so I am not particularly worried about empty pings. I wanted to get some tips around how to ensure redundancy for such a polling process. If I have only one process (let's call it A) then there is no backup in case A fails. If I create two processes A&B then how do I ensure that only one process is polling the database at a time and the other process kicks in only if the first one fails.

I understand this question is too broad, however, I would appreciate any pointers about the latest design patterns or frameworks that will help me achieve redundancy. I can use Java instead of Python if it will work better.

prats
  • 225
  • 5
  • 15

1 Answers1

0

You will need to keep the state/result of the ping and make it available to both processes. This could be kept in a cache, a file, etc. Have one process ping and write a last-updated timestamp to the file/cache/etc. The other process only runs if the file/cache/etc isn't updated.

This sort of process is encapsulated in distributed lock handlers and cluster managers like Apache Zookeeper.

Rob Conklin
  • 8,806
  • 1
  • 19
  • 23