2 ms·
Using a Rack endpoint only reduces the overhead for that specific expensive call. For example if you have a Net:Http.get_request in a Rack endpoint that takes 3
by aarongough 16y ago
Using a Rack endpoint only reduces the overhead for that specific expensive call. For example if you have a Net:Http.get_request in a Rack endpoint that takes 3 seconds to complete then that Rack endpoint isn't going to be any faster than writing a Rails controller action that does the same thing.
If the whole thing were handled asynchronously though you would be able to handle dozens of requests (if not hundreds) in the same time that blocking NET:Http.get_request would take to complete.
- grandalf 16y agoTrue.. not sure Rails necessarily needs to be the right tool for every job, though. If I had a workflow like that I would probably not use Rails.
- aarongough 16y agoThat's totally true. And as I said in another comment I have come up against this exact problem and had considered switching to Node.js to fix it. But when it comes down to it, hacking Rails to do async requests is going to teach me a lot about how Rack and Thin work, so that's why I'm continuing to push in that direction.