Sitting here with a simple rail 3 application, in which I have a simple gallery model, and each gallery has many images. The image model is expanded with a paper clip and with the following parameters
has_attached_file :local, :styles => { :large => "800x800>", :medium => "300x300>", :thumb => "100x100#", :small => "60x60#" }
In my galleries_controller I have the following action that is implemented to work with the jQuery-File-Upload plugin. so the answer is json.
def add_image gallery = Gallery.find params[:id] image = gallery.images.new({:local => params[:local]}) if image.save render :json => {:thumb => image.url(:thumb), :original => image.url} else render :json => { :result => 'error'} end end
For me it's pretty straight forward. But there is a problem. In development for mongrel, any type of upload works with just 500-1000ms / upload.
However, when I push it to production, I constantly get timeouts for my unicorns, and when it sends an image through it, it takes 30 to 55 seconds for a single file.
download files about 100 thousand in size
I did some bandwidth testing between my VPS and my witH ipref dev computer and got an average speed of about 77 Kbps, so downloading should not be a problem.
Note. I also checked the test with downloading a file without ajax using the same application with a user model that has an avatar. Development => Completed 302 Found in 693ms Production => Completed 302 Found in 21618 m.
Has anyone encountered a similar problem while downloading files (rails3, unicorn)?