I use Sidekiq in my rails application to create 50,000+ jobs at the same time. The size of our pool is 9.
The works are related to each other and do the same. We have another model on which there is a counter. During each task, we check whether this model has a column with a value above 200. If it is above 200, we create another instance of this model with a value = 0 and continue working. However, since we have 9 tasks to be performed at a time, all 9 tasks read the value of this column, which should be more than 200 at the same time, and everyone creates new instances, which is incorrect.
What is the best way to solve this problem? Basically, we want all assignments to be read from the most recent value.
ruby-on-rails sidekiq
Matthew berman
source share