开发者

How to improve performance with our Rails image model and attachment_fu?

I've been trying to improve performance our app. The worst performing area seems to be the creation of our Image model, which uses attachment_fu:

class Image < Attachment

  ...

  has_attachment :content_type => :image,
    :max_size => 100.megabytes,
    :storage => :file_system,
    :path_prefix => 'public/uploaded/images',
    :thumbnails => { :small => '75x75>', :medium => '160x120>', :large => '600x600>' },
    :s3_access => :authenticated_read

  validates_as_attachment

  after_create :move_to_s3

  ...

We've already moved the move_to_s3 method to a delayed_job.

Our apdex score on this transaction is horrible (often < 0.5) and it's taking 1 to 2 seconds.

How else can I impr开发者_JAVA技巧ove the creation of Image records (speed-wise)?

I may be able to do without the :small thumbnail? Would it help to drop that?

If it helps, most of these files are high-res images. Does the upload time factor into the metrics I have? Is it skewing the reports?


I would save the image directly to S3, then created a delayed job to download it, resize it, and put the thumbnails back in S3.

To show the image on the next page load, just link to the large version and resize it via css.

Also, yes, the fewer sizes you need, the less processing it will take.


You could use mod_porter to let the webserver handle the upload, instead of your app.

This isn't going to "speed up" anything, but it will keep one of your app servers from blocking until the file is actually uploaded.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜