Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Is Rails 4 going to render JSON as a stream by default?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Rodrigo Rosenfeld Rosas  
View profile  
 More options Nov 1 2012, 10:14 am
From: Rodrigo Rosenfeld Rosas <rr.ro...@gmail.com>
Date: Thu, 01 Nov 2012 12:14:50 -0200
Local: Thurs, Nov 1 2012 10:14 am
Subject: Is Rails 4 going to render JSON as a stream by default?
I have some pretty big data to be encoded to JSON in my application and
it would be faster if rendering my data as JSON could be done with a
stream response.

So, if the network is the bottleneck, the clients wouldn't notice some
seconds of delay before starting to receive the JSON response that is
required for the server to process JSON encoding before starting to send
it to the client...

Are you considering any kind of optimization like this for Rails 4?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Piotr Sarnacki  
View profile  
 More options Nov 1 2012, 10:24 am
From: Piotr Sarnacki <dro...@gmail.com>
Date: Thu, 1 Nov 2012 15:23:50 +0100
Local: Thurs, Nov 1 2012 10:23 am
Subject: Re: [Rails-core] Is Rails 4 going to render JSON as a stream by default?

As far as I know there is no plans to make it the default, but nothing
stops you from using ActionController::Live to stream JSON as soon as you
generate it.

On Thu, Nov 1, 2012 at 3:14 PM, Rodrigo Rosenfeld Rosas
<rr.ro...@gmail.com>wrote:

--
Piotr Sarnacki
http://piotrsarnacki.com

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rodrigo Rosenfeld Rosas  
View profile  
 More options Nov 1 2012, 11:35 am
From: Rodrigo Rosenfeld Rosas <rr.ro...@gmail.com>
Date: Thu, 01 Nov 2012 13:35:40 -0200
Local: Thurs, Nov 1 2012 11:35 am
Subject: Re: [Rails-core] Is Rails 4 going to render JSON as a stream by default?

It is not as simple as one might think.

It requires streaming support by the JSON library itself since the point
is to start streaming the output *before* the JSON encoding is finished.

You should be able to pass the output streaming buffer object to the
JSON formatter library. For instance, suppose you have something like
this object:

{keyA: 'a value', keyB: anotherObject}

As the JSON formatter library reads this object, it would start with
some key, right? Suppose it starts with "keyA". So the browser would get
a chunk like this:

{"keyA": "a value"

Then it would get another chunk like:

, "keyB":

And it goes on until all object processing is finished. Of course I just
simplified the idea. What would really give a boost in my case would be
the ability to use multiple cores to format the JSON by splitting the
task in multiple threads (or processes depending on what Ruby
implementation the library is targetting to).

Since JSON became the de facto format to exchange data between servers
and browsers any effort to speed up its encoding/decoding (specially
encoding) would be of much value to any web framework.

I'd love to see some performance improvements over JSON responses.

Unfortunately I don't have time this year to work on such improvements
since I'm currently with a very tight deadline that has been already
missed due to Sandy's hurricane that affected our collocation service
provider in NYC.

Please let me know if I wasn't clear enough of what performance
improvements I'm suggesting to Rails 4 with regards to JSON responses.

Best,
Rodrigo.

Em 01-11-2012 12:23, Piotr Sarnacki escreveu:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Piotr Sarnacki  
View profile  
 More options Nov 1 2012, 11:57 am
From: Piotr Sarnacki <dro...@gmail.com>
Date: Thu, 1 Nov 2012 16:56:41 +0100
Local: Thurs, Nov 1 2012 11:56 am
Subject: Re: [Rails-core] Is Rails 4 going to render JSON as a stream by default?

On Thu, Nov 1, 2012 at 4:35 PM, Rodrigo Rosenfeld Rosas
<rr.ro...@gmail.com>wrote:

>  It is not as simple as one might think.

I'm aware that you need to have the library support for that, but this is
not a rails concern. Rails depends on multi_json (well, technically Active
Support depends on it) and you can choose any library you want to render
JSON with rails. If you need this kind of feature, you should rather talk
with maintainers of one of the JSON libraries out there.

--
Piotr Sarnacki
http://piotrsarnacki.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Pankowecki  
View profile  
 More options Nov 2 2012, 7:48 am
From: Robert Pankowecki <robert.pankowe...@gmail.com>
Date: Fri, 2 Nov 2012 12:48:39 +0100
Local: Fri, Nov 2 2012 7:48 am
Subject: Re: [Rails-core] Is Rails 4 going to render JSON as a stream by default?

https://github.com/brianmario/yajl-ruby

Yajl is capable of doing it. So hacking together Yajl and
ActionController::Live
might give you streaming json as it is produced.

Robert Pankowecki


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rodrigo Rosenfeld Rosas  
View profile  
 More options Nov 6 2012, 12:17 pm
From: Rodrigo Rosenfeld Rosas <rr.ro...@gmail.com>
Date: Tue, 06 Nov 2012 15:17:04 -0200
Local: Tues, Nov 6 2012 12:17 pm
Subject: Re: [Rails-core] Is Rails 4 going to render JSON as a stream by default?

Thank you, Robert, I'll give it a try once Rails 4 is released.

Em 02-11-2012 09:48, Robert Pankowecki escreveu:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »