Using Primary/Unique Key in Database to Improve Resilience by Spawning Multiple Readers

in hive-102132 •  6 hours ago 

The Steem Blockchain Bots is based on the following design:

  1. A reader process monitors the latest transactions on steem blockchain, and writes the corresponding command e.g. !ask to database.
  2. A writer process reads the latest command, and performs the corresponding bot action and then finally post a comment.

If there is only 1 reader, when the reader is down/offline for maintenance, the latest transactions may be missed. Therefore, I've spawned additional multiple readers and ensure only single record is inserted into the database, thanks to the primary/unique key enforcement criteria.

This greatly improves the resilience.

As shown, only 1 writes, other readers fails with DUP_KEY error
6c67087ba66ce6d53c7a4c8cb983821.png

Steem to the Moon🚀!

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!