Attachment_fu timeouts on EC2

Posted by Bruno
on Friday, July 06

Quick note: running into timeouts when uploading photos to S3 using attachment_fu on EC2 (that’s a mouthful)?

I think I tracked down the problem. Actually, I tracked down someone else who tracked down the problem: http://rubyforge.org/pipermail/amazon-s3-dev/2007-April/000072.html

Turns out the default for the aws/s3 library is to use persistent connections, which apparently cause intermittent timeouts.

Solution: use non-persistent connections by doing this in your attachment_fu/backends/s3_backend.rb:

          Base.establish_connection!(
            :access_key_id     => s3_config[:access_key_id],
            :secret_access_key => s3_config[:secret_access_key],
            :server            => s3_config[:server],
            :port              => s3_config[:port],
            :use_ssl           => s3_config[:use_ssl],
            :persistent        => s3_config[:use_persistent]
          )

Then you can add a line to your amazon_s3.yml like this:

production:
  bucket_name: your_app_production
  access_key_id: 'YOUR_ACCESS_KEY_ID'
  secret_access_key: 'YOUR_SECRET_ACCESS_KEY'
  use_persistent: false
Comments

Leave a response

  1. Andrew KuklewiczJuly 06, 2007 @ 08:55 PM

    I’m confused. Your comments imply persistent being true is the problem, meaning peristent should be false. However, our yaml entry shows: “use_persistent: true” – did you mean that to be false instead?

  2. Jeffrey HardyJuly 08, 2007 @ 11:55 AM

    I’ve run into this problem too. Non-persistent connections are the way to go for now.

  3. HamptonJuly 08, 2007 @ 10:31 PM

    We’ve had this problem at Unspace…

    not on EC2 servers.