3 ms·
Disclaimer: I didn't try this with rails, but tried this with Django, so YMMV Yes, the request will take more or less the same time But 'pushing' the data thr
by raverbashing 14y ago
Disclaimer: I didn't try this with rails, but tried this with Django, so YMMV
Yes, the request will take more or less the same time
But 'pushing' the data through rails/php/python uses a lot of CPU
"will occupy a web process for the same duration" no, because then the server will do the work
The real question is the CPU usage, if you measured it and it's acceptable, congrats. (In my Django tests, it was around 40% - for one request streaming video)
The issue is that, for static data (like files), NGINX (and Apache) can serve a huge amount of requests without flinching.
One way to do it is like this: http://wiki.nginx.org/XSendfile http://wiki.nginx.org/XSendfile then your RoR app sends the request to NGINX and it will send the file (and this works with the streaming modules so you can pass the start position, etc)
- robotmay 14y agoOh when it comes to streaming files then I totally agree that the server should do the work. This is more about reducing the visible load time for dynamic pages on a site. My example points to my site (e.g. http://daysoutnearme.com/hubs/city/bath http://daysoutnearme.com/hubs/city/bath) which uses it to improve the load speed of a heavy processing page; the map loads instantly when the remaining chunks of the page come through as the JavaScript has already been processed by the browser.
- raverbashing 14y agoYes, sorry about that, I guess I read 'streaming/chuncking' and got carried away After reading the article I have to say it's quite interesting, and rails makes it very easy to do.