I am writing a rake task that will be called every minute (maybe every 30 seconds in the future) when
Beware of the Rails launch time, it might be better to use a forking model like Resque or Sidekiq, Rescue provides https://github.com/bvandenbos/resque-scheduler , which should be able to do what you need, I donβt I can talk about Sidekiq, but I'm sure it has something similar (Sidekiq is much newer than Resque)
Obviously, this does not work effectively as a single thread, but is multithreading possible? If not, is there a good event-based HTTP library that can do the job?
I would advise you to take a look at ActiveRecord find_each for tips on improving the efficiency of your search process, as soon as you have your parties you can easily do something using threads such as:
#
This will start no more than batch_size threads waiting for each batch_size .
You could do something like this, but then you will have an uncontrolled number of threads, there is an alternative that you can extract from this, it becomes much more difficult, including ThreadPool, and a general list of work to be done, I published it as in Github so no spam stackoverflow: https://gist.github.com/6767fbad1f0a66fa90ac
source share