How get best performance rails requests parallel sidekiq worker

谁说我不能喝 提交于 2019-12-01 01:23:49

Inside the worker, spawn application level Threads.

For example, Create 10 ruby threads to process the 2500 external api requests(means each ruby thread will process 250 requests).

  # threads will contain the threads
  threads = [] 
external_requests.each_slice(250) do |group| threads << Thread.new(group) do |tsrc| tsrc.each do |ex_request| # Do your external call here end end end threads.each(&:join) # wait for all threads to finish
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!