Rails - sending multiple http requests to a another server

不问归期 提交于 2019-12-12 03:28:29

问题


1000 users make a request to my Rails server at exactly the same time. For each user, I need to make 50 http requests to other servers, each taking 1 second to respond. How do I go about coding my application so that I can respond to the users as quickly as possible?

(Note: the app hasn't launched and the numbers are hypothetical.)


回答1:


I think you need to implement a Job queuing system with ActiveJob and for example Sidekiq.

So your workers can make these 50 http requests.

You'll have to tell the user to be patient while your server is making these requests. This way, the user get's instantly a message which says that there's something going on, you could then notify the user if the jobs have finished.



来源:https://stackoverflow.com/questions/38453330/rails-sending-multiple-http-requests-to-a-another-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!