I have made an app for a friend running on heroku, www.wafflehearts.com,
which uses dragonfly for the images. I have been seeing issues with
page loads of the main page, and sometimes it takes over 30 seconds
which means that the user ends up with an error instead of the actual
page.
I am going to try to include all the relevant information, but please
feel free to ask for additional details that could help debug why the
image loading/generation is slowing down things so much
==== config/initializers/dragonfly.rb ====
require 'dragonfly'
app = Dragonfly[:images]
app.configure_with(:imagemagick)
app.configure_with(:rails)
app.configure_with(:heroku, 'anne-website') if Rails.env.production?
Apologies if some of the configuration/code provided is not relevant,
but I figured I would rather err on the side of too much information.
I am wondering whether this could be a cache issue, or something to do
with me requesting the width and height of the thumbs?
I used to do:
==== app/views/recipe/index.html.erb ====
<% for recipe in @recipes %>
< … >
<% if recipe.cover_image_uid %>
<%= link_to image_tag(recipe.cover_image.thumb('150x150').url,
{:height => recipe.cover_image.thumb('150x150').height, :width =>
recipe.cover_image.thumb('150x150').width, :class => "align-left"}),
recipe_url %>
<…>
------------------------------------------------------------
which was causing the pages to fail to load. As you can see, I
optimized that a bit which reduced the page loading time to ~10-15
sec, but that still seems very slow, and I am hoping with your help I
can speed this up. Unless I can figure this out, my next step would be
to regenerate the thumb images of this size, but I was hoping to avoid
having multiple versions of the images when using dragonfly.
Just to prove that it isn't any of my db transactions slowing things down, I have used the new relic service to narrow down the response time of loading the main index page (see screenshot). As you can see, the active record calls are all pretty fast, while the rendering of the view is the slow part.
On Friday, 18 May 2012 14:24:00 UTC-7, ccjensen wrote:
> Hi,
> I have made an app for a friend running on heroku, www.wafflehearts.com, > which uses dragonfly for the images. I have been seeing issues with > page loads of the main page, and sometimes it takes over 30 seconds > which means that the user ends up with an error instead of the actual > page.
> I am going to try to include all the relevant information, but please > feel free to ask for additional details that could help debug why the > image loading/generation is slowing down things so much > ==== config/initializers/dragonfly.rb ==== > require 'dragonfly' > app = Dragonfly[:images]
> app.configure_with(:imagemagick) > app.configure_with(:rails) > app.configure_with(:heroku, 'anne-website') if Rails.env.production?
> Apologies if some of the configuration/code provided is not relevant, > but I figured I would rather err on the side of too much information. > I am wondering whether this could be a cache issue, or something to do > with me requesting the width and height of the thumbs?
> I used to do: > ==== app/views/recipe/index.html.erb ==== > <% for recipe in @recipes %> > < … > > <% if recipe.cover_image_uid %> > <%= link_to > image_tag(recipe.cover_image.thumb('150x150').url, > {:height => recipe.cover_image.thumb('150x150').height, :width => > recipe.cover_image.thumb('150x150').width, :class => "align-left"}), > recipe_url %> > <…> > ------------------------------------------------------------ > which was causing the pages to fail to load. As you can see, I > optimized that a bit which reduced the page loading time to ~10-15 > sec, but that still seems very slow, and I am hoping with your help I > can speed this up. Unless I can figure this out, my next step would be > to regenerate the thumb images of this size, but I was hoping to avoid > having multiple versions of the images when using dragonfly.
The way I understand it - when you use something like this recipe.cover_image.thumb('150x150').height, dragonfly calls ImageMagick to get the height from the actual file. This operation is costly, and you use it a lot.
I suggest to design your site that the thumbnails are always 150px in width and 150px in height, so you can just hardcode these values.
On Friday, May 18, 2012 11:31:19 PM UTC+2, ccjensen wrote:
> Just to prove that it isn't any of my db transactions slowing things down, > I have used the new relic service to narrow down the response time of > loading the main index page (see screenshot). As you can see, the active > record calls are all pretty fast, while the rendering of the view is the > slow part.
> On Friday, 18 May 2012 14:24:00 UTC-7, ccjensen wrote:
>> Hi,
>> I have made an app for a friend running on heroku, www.wafflehearts.com, >> which uses dragonfly for the images. I have been seeing issues with >> page loads of the main page, and sometimes it takes over 30 seconds >> which means that the user ends up with an error instead of the actual >> page.
>> I am going to try to include all the relevant information, but please >> feel free to ask for additional details that could help debug why the >> image loading/generation is slowing down things so much >> ==== config/initializers/dragonfly.rb ==== >> require 'dragonfly' >> app = Dragonfly[:images]
>> app.configure_with(:imagemagick) >> app.configure_with(:rails) >> app.configure_with(:heroku, 'anne-website') if Rails.env.production?
>> Apologies if some of the configuration/code provided is not relevant, >> but I figured I would rather err on the side of too much information. >> I am wondering whether this could be a cache issue, or something to do >> with me requesting the width and height of the thumbs?
>> I used to do: >> ==== app/views/recipe/index.html.erb ==== >> <% for recipe in @recipes %> >> < … > >> <% if recipe.cover_image_uid %> >> <%= link_to >> image_tag(recipe.cover_image.thumb('150x150').url, >> {:height => recipe.cover_image.thumb('150x150').height, :width => >> recipe.cover_image.thumb('150x150').width, :class => "align-left"}), >> recipe_url %> >> <…> >> ------------------------------------------------------------ >> which was causing the pages to fail to load. As you can see, I >> optimized that a bit which reduced the page loading time to ~10-15 >> sec, but that still seems very slow, and I am hoping with your help I >> can speed this up. Unless I can figure this out, my next step would be >> to regenerate the thumb images of this size, but I was hoping to avoid >> having multiple versions of the images when using dragonfly.
On Monday, 25 June 2012 11:47:55 UTC-7, Aleksandr Lossenko wrote:
> The way I understand it - when you use something like > this recipe.cover_image.thumb('150x150').height, dragonfly calls > ImageMagick to get the height from the actual file. This operation is > costly, and you use it a lot.
> I suggest to design your site that the thumbnails are always 150px in > width and 150px in height, so you can just hardcode these values.
> On Friday, May 18, 2012 11:31:19 PM UTC+2, ccjensen wrote:
>> Just to prove that it isn't any of my db transactions slowing things >> down, I have used the new relic service to narrow down the response time of >> loading the main index page (see screenshot). As you can see, the active >> record calls are all pretty fast, while the rendering of the view is the >> slow part.
>>> which uses dragonfly for the images. I have been seeing issues with >>> page loads of the main page, and sometimes it takes over 30 seconds >>> which means that the user ends up with an error instead of the actual >>> page.
>>> I am going to try to include all the relevant information, but please >>> feel free to ask for additional details that could help debug why the >>> image loading/generation is slowing down things so much >>> ==== config/initializers/dragonfly.rb ==== >>> require 'dragonfly' >>> app = Dragonfly[:images]
>>> app.configure_with(:imagemagick) >>> app.configure_with(:rails) >>> app.configure_with(:heroku, 'anne-website') if Rails.env.production?
>>> Apologies if some of the configuration/code provided is not relevant, >>> but I figured I would rather err on the side of too much information. >>> I am wondering whether this could be a cache issue, or something to do >>> with me requesting the width and height of the thumbs?
>>> I used to do: >>> ==== app/views/recipe/index.html.erb ==== >>> <% for recipe in @recipes %> >>> < … > >>> <% if recipe.cover_image_uid %> >>> <%= link_to >>> image_tag(recipe.cover_image.thumb('150x150').url, >>> {:height => recipe.cover_image.thumb('150x150').height, :width => >>> recipe.cover_image.thumb('150x150').width, :class => "align-left"}), >>> recipe_url %> >>> <…> >>> ------------------------------------------------------------ >>> which was causing the pages to fail to load. As you can see, I >>> optimized that a bit which reduced the page loading time to ~10-15 >>> sec, but that still seems very slow, and I am hoping with your help I >>> can speed this up. Unless I can figure this out, my next step would be >>> to regenerate the thumb images of this size, but I was hoping to avoid >>> having multiple versions of the images when using dragonfly.