Rails - sending multiple http requests to a anothe

2019-09-12 14:06发布

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条回答
Explosion°爆炸
2楼-- · 2019-09-12 14:14

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.

查看更多
登录 后发表回答