technoweenie / attachment_fu

Treat an ActiveRecord model as a file attachment, storing its patch, size, content type, etc.
http://weblog.techno-weenie.net
MIT License
1.02k stars 337 forks source link

Cloudfile cdn down cause passenger completely to freeze #24

Closed smeevil closed 14 years ago

smeevil commented 14 years ago

Hi there,

Today 19 Aug 2010 cloudfiles CDN had a problem. When i deployed a project that uses attachment_fu with :storeage=>:cloudfiles it pulled down my complete passenger setup. Not sure what caused this except that moving storage back to filesystem solved the imminent problem.

Will update once i have had time to figure out what exactly is causing this.

Narnach commented 14 years ago

An initial investigation leads to this section in lib/technoweenie/attachment_fu/backends/cloud_file_backend.rb:

module CloudFileBackend
  def self.included(base)
    # ...
    @@cf = CloudFiles::Connection.new(@@cloudfiles_config[:username], @@cloudfiles_config[:api_key])
    @@container = @@cf.container(@@container_name)
    # ...
  end
end

This will try to connect and authenticate with the CloudFile server and then obtain the container. The problem is that if there is nobody listening on the other side, or if it takes ages and ends in a timeout, that this stalls the code loading at this point.

technoweenie commented 14 years ago

It's best not to upload your files to any remote service in your rails app. Do this stuff in a background queue.