Serious drag on JSON rendering

21 views
Skip to first unread message

Micah Alcorn

unread,
Feb 7, 2012, 4:14:06 PM2/7/12
to carrierwave
I have two applications where JSON is rendered by a Rails API for use
on a mobile client. Both apps use CarrierWave 0.5.8 with Rails 3.1+
and Fog to connect to Rackspace Cloud Files. One uses mongoid and the
other activerecord.

In both cases, if my controller retrieves an array and renders HTML,
there is no problem. But if I render JSON and the model includes a CW
attachment, the rendering is exponentially slower. For example, my
User has many Photos, each containing an Image (CW). If
@current_user.photos.count == 13, then the Rails default JSON render
will take about ninety (90) seconds! Rendering HTML might take three
(3) seconds.

However, if I use json_builder and do not include Image object, then
JSON rendering takes approximately the same amount of time as HTML.
Then I have to reconstruct the Image urls manually on the client side,
which is don't think is a good long term solution.

Is this normal, or am I missing something? Thanks!

Daniel Doubrovkine

unread,
Feb 9, 2012, 12:10:18 AM2/9/12
to carri...@googlegroups.com
You're probably hitting Fog and then Rackspace to figure out an URL or something like that. It will take some debugging - we had one of our functions on the image uploader calling something in Carrierwave that resulted in a remote call.


--
You received this message because you are subscribed to the Google Groups "carrierwave" group.
To post to this group, send email to carri...@googlegroups.com.
To unsubscribe from this group, send email to carrierwave...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/carrierwave?hl=en.




--

dB. | Moscow - Geneva - Seattle - New York
dblock.org - @dblockdotorg


Reply all
Reply to author
Forward
0 new messages