Is Rails 3.1 still lacking real streaming support?

I remember that some time ago I did want to generate an HTML table in which each row would take several seconds for generating each line.

And I wanted to be able to view the generated HTML file as the rows were processed.

At that time, Rails didn't support this. Am I right in assuming that even Rails 3.1 won't support this kind of streaming support?

I mean, consider that my view won't set any variables for the layout to be aware about. So the layout would be just plain HTML with a single "yield".

Then, I would like to be able to send my response as they are generated. Is that kind of support planned to be added in some later version of Rails?

Cheers and have a good weekend and holiday for those in USA,

Rodrigo.

I remember that some time ago I did want to generate an HTML table in which
each row would take several seconds for generating each line.

And I wanted to be able to view the generated HTML file as the rows were
processed.

At that time, Rails didn't support this. Am I right in assuming that even
Rails 3.1 won't support this kind of streaming support?

I mean, consider that my view won't set any variables for the layout to be
aware about. So the layout would be just plain HTML with a single "yield".

In 3.1, only the layout is streamed, so the table would be buffered.

In addition to that, producion setups have gotchas. For example, if
you use nginx + Unicorn with the recommended configuration, streaming
will technically work, but it only gets to nginx who buffers the
entire response. So in practice the client is not seeing the benefits.

In addition to that, the proxy of ngnix is 1.0, so it sends a 1.0
request to the proxied server. And Rails disables streaming for 1.0
requests because it is a 1.1 feature. They were trying to come with a
workaround for that somehow, not sure which is the situation as of
today.

There's also the problem with compression, if you have it enabled
(which is a standard practice in normal production setups). The web
server should be able to dechunk, compress, and chunk the compressed
content, everything on the fly. The only combo that worked for me when
I did research about this a few weeks ago was Apache + Unicorn. Hongli
was also working on it for Passenger, I don't know which is the status
right now.

In general, this feature has to be considered experimental today.

Then, I would like to be able to send my response as they are generated. Is
that kind of support planned to be added in some later version of Rails?

Yes, it is in the radar, perhaps in some future version.

[Reposting this because it does not seem to arrive, please excuse if
you get it twice.]

I remember that some time ago I did want to generate an HTML table in
which each row would take several seconds for generating each line.

And I wanted to be able to view the generated HTML file as the rows were
processed.

At that time, Rails didn't support this. Am I right in assuming that
even Rails 3.1 won't support this kind of streaming support?

I mean, consider that my view won't set any variables for the layout to
be aware about. So the layout would be just plain HTML with a single
"yield".

In 3.1, only the layout is streamed, so the table would be buffered.

In addition to that, producion setups have gotchas. For example, if
you use nginx + Unicorn with the recommended configuration, streaming
will technically work, but it only gets to nginx who buffers the
entire response. So in practice the client is not seeing the benefits.

In addition to that, the proxy of ngnix is 1.0, so it sends a 1.0
request to the proxied server. And Rails disables streaming for 1.0
requests because it is a 1.1 feature. They were trying to come with a
workaround for that somehow, not sure which is the situation as of
today.

There's also the problem with compression, if you have it enabled
(which is a standard practice in normal production setups). The web
server should be able to dechunk, compress, and chunk the compressed
content, everything on the fly. The only combo that worked for me when
I did research about this a few weeks ago was Apache + Unicorn. Hongli
was also working on it for Passenger, I don't know which is the status
right now.

In general, this feature has to be considered experimental today.

Then, I would like to be able to send my response as they are generated.
Is that kind of support planned to be added in some later version of Rails?

Yes, it is in the radar, perhaps in some future version.

Wow, Xavier, thank you very much for the detailed status report of the current situation of streaming support in Rails and Ruby servers :slight_smile:

I appreciate that a lot!

Cheers,

Rodrigo.