6 ms·
I'm not sure I understand your last line there. The request takes exactly the same amount of time as if you weren't using Rails' streaming support and will occu
by robotmay 14y ago
I'm not sure I understand your last line there. The request takes exactly the same amount of time as if you weren't using Rails' streaming support and will occupy a web process for the same duration; it just results in some of the data being sent before the response is complete. This yields no net performance increase/decline; it's merely an improvement of the user experience.
And yes, there are plenty of ways to perform streaming in the web server itself. I'm not talking about that, but please feel free to write up a post of how to do that and achieve similar results; I'd be genuinely interested.
- raverbashing 14y agoDisclaimer: 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.