carrierwave-dropbox icon indicating copy to clipboard operation
carrierwave-dropbox copied to clipboard

Slow attachment.url's

Open izelnakri opened this issue 10 years ago • 10 comments

The Following code fixes slow rendering / url retrieval issues when a model has an attachment.url:

class ImageUploader < CarrierWave::Uploader::Base

 def url  
 "dropbox_endpoin_manually_typed/#{path}" if path
  end
end

Before the fix = (Views: ~1800ms | ActiveRecord: 0.7ms)

After the fix = (Views: ~10ms | ActiveRecord: 0.7ms)

izelnakri avatar Mar 24 '14 21:03 izelnakri

Hello @izelnakri,

Thanks for reporting! Sorry for the late reply, I will try to take a look soon!

robin850 avatar Apr 06 '14 10:04 robin850

there are actually more issues with this gem, just like its paperclip sibling. Some of the issues I've raised in the paperclip gem is relevant for this gem as well. Please take a look at it: https://github.com/janko-m/paperclip-dropbox/issues/36.

I wish I could contribute to the gem since it seems like one of the worst gems I'm currently using so far, days of frustration over some wrong implementations or bad conventions. (No offense here, just objective opinion). However I'm not very good with metaprogramming in ruby yet. Thanks for your interest!

izelnakri avatar Apr 06 '14 10:04 izelnakri

@izelnakri , @robin850 I have same issue right now. However I can't simply specify Dropbox URL as it changes each time I upload file, for example:

dl.dropboxusercontent.com/1/view/df106vuup1mzftx/Apps/[YOURAPP/[YOURFILE] dl.dropboxusercontent.com/1/view/mxbs026yru67ln0/Apps/[YOURAPP/[YOURFILE] dl.dropboxusercontent.com/1/view/2cc9lrqlglfxga3/Apps/[YOURAPP/[YOURFILE]

ghost avatar Apr 10 '15 09:04 ghost

Here is the command line output with rendering times of one view and 2 linked pictures: screen shot 2015-04-10 at 2 07 59 pm

Now the same view, no images (I commented out the whole link): screen shot 2015-04-10 at 3 02 36 pm

I repeat, this happens notoriously and I am trying to investigate whats wrong with the routing urls of this gem.

ghost avatar Apr 14 '15 08:04 ghost

I am having similar issues with this gem as for as performance is concerned. I don't see any optimizations which are done on this, are there any tweaks we can do to avoid this performance issue.

smmanoj avatar Apr 30 '15 12:04 smmanoj

Hi there!

Sorry for the very late response! Actually I'm wondering whether the problem lies in this gem ; this seems to be a problem on the dropbox_sdk gem:

require 'benchmark'
require 'dropbox_sdk'

session = DropboxSession.new("app_key", "app_secret")
session.set_access_token("access_token", "acces_token_secret")
client = DropboxClient.new(session, "dropbox")

puts Benchmark.measure {
  client.media("/path/to/existing/image.png")["url"]
}

It takes a whole second to run on my computer:

  0.010000   0.000000   0.010000 (  1.055575)

I will further investigate, thanks for reporting guys! :+1:

robin850 avatar May 04 '15 20:05 robin850

I am having similar issue too

sdilshod avatar May 24 '15 18:05 sdilshod

I am having similar issue too

cotorusso avatar Feb 25 '16 21:02 cotorusso

Just wanted to confirm that the issue lies with dropbox_sdk gem (as @robin850 mentioned). I have run benchmarks on every method down the call stack, and the only point where it significantly slows down (sometimes up to 2 seconds!) is main HTTP call inside Dropbox SDK

koss-lebedev avatar Nov 04 '16 16:11 koss-lebedev

Hi, I am experiencing same issue, image taking too much time. Can anyone tell me whether this gem directly uploads image on dropbox or server is involved in uploading image to dropbox? Because a friend of mine told me that if your server is doing this part then its gonna crush when there are 5 or 6 requests simultaneously.

zia-qamar avatar Sep 19 '17 10:09 zia-qamar