My app makes http requests to another server on behalf of users. This question concerns doing this in the optimal way.
The app may need to return the result of many http requests (to foreign server) to a user as quickly as possible. I have used threading to optimise this as best I can. However, I don't know enough to understand what happens when multiple users use the site at once. Bizarrely, when I simulated a few users making requests to the (local) development server at the same time, the response time didn't appear to suffer at all.
I was thinking of making a class that queues http requests and processes them when it can, however, I wouldn't know whether to instantiate it at App level or User level.
The local Web server is webrick and the production server is puma.
Questions:
- What happens when multiple users make requests to my site (where, for each request, my site must in turn make multiple requests to another site)?
- How do I optimise response times?
- Is having the users of my site send requests to the foreign site directly (ajax) a possibility?