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
Page loads really slow on Heroku
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
  4 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
 
ccjensen  
View profile  
 More options May 18 2012, 5:24 pm
From: ccjensen <christophercjen...@gmail.com>
Date: Fri, 18 May 2012 14:24:00 -0700 (PDT)
Subject: Page loads really slow on Heroku
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?

app.define_macro(ActiveRecord::Base, :image_accessor)
------------------------------------------------------------

==== config/environments/production.rb ====
Annebeaubien::Application.configure do
  config.cache_classes = true
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true
  config.serve_static_assets = false
  config.assets.compress = true
  config.assets.compile = false
  config.assets.digest = true
<…>
------------------------------------------------------------

==== config/application.rb ====
module Annebeaubien
  class Application < Rails::Application
<…>
    config.assets.enabled = true
    config.assets.version = '1.0'
    config.assets.initialize_on_precompile = false
    config.middleware.insert 0, 'Dragonfly::Middleware', :images
  end
end
------------------------------------------------------------

==== app/model/recipe.rb ====
class Recipe < ActiveRecord::Base
    image_accessor :cover_image do
        storage_path{|a| "recipes/images/#{Time.now.iso8601.gsub(":",
"_")}/#{rand(100)}-#{CGI.escape title}.#{a.format}" }
    end
<…>
------------------------------------------------------------

==== app/views/recipe/index.html.erb ====
<% for recipe in @recipes %>
        < … >
        <% if recipe.cover_image_uid %>
                <% image = recipe.cover_image.thumb('150x150') %>
                <%= link_to image_tag(image.url, {:height => image.height, :width =>
image.width, :class => "align-left"}), recipe_url %>
<…>
------------------------------------------------------------

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.

Thanks for any and all suggestions.
Chris


 
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.
ccjensen  
View profile  
 More options May 18 2012, 5:31 pm
From: ccjensen <christophercjen...@gmail.com>
Date: Fri, 18 May 2012 14:31:19 -0700 (PDT)
Local: Fri, May 18 2012 5:31 pm
Subject: Re: Page loads really slow on Heroku

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.

<https://lh3.googleusercontent.com/-A1gv07BpkNg/T7a_f8qFFeI/AAAAAAAAAE...>
Hope someone can make some suggestions as to what I am doing wrong, or how
I have misconfigured things.
Chris


 
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.
Aleksandr Lossenko  
View profile   Translate to Translated (View Original)
 More options Jun 25 2012, 2:47 pm
From: Aleksandr Lossenko <aleksandr.losse...@gmail.com>
Date: Mon, 25 Jun 2012 11:47:55 -0700 (PDT)
Local: Mon, Jun 25 2012 2:47 pm
Subject: Re: Page loads really slow on Heroku

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.


 
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.
ccjensen  
View profile  
 More options Jul 12 2012, 7:12 pm
From: ccjensen <christophercjen...@gmail.com>
Date: Thu, 12 Jul 2012 16:12:13 -0700 (PDT)
Local: Thurs, Jul 12 2012 7:12 pm
Subject: Re: Page loads really slow on Heroku

Thanks, Aleksandr. I will give that a try, and report back whether I see
improvements!


 
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 »