Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Carrierwave or Dragonfly

I have been looking into rails file upload tools and the ones that seemed the most appealing and interesting to me were carrierwave and dragonfly.

From looking around it seems like carrierwave takes the more traditional style where you can process the file on save whereas dragonfly is middleware so it allows you to process on the fly.

I was wondering if people had any references to performance test or any test that compare the two.

Also, just curious on what people's opinions are about both and which they prefer and of course why they prefer it.

like image 263
Danish Khan Avatar asked Sep 20 '10 21:09

Danish Khan


2 Answers

Depending on the setup. As Senthil writes, as long as you have a cache-proxy in front, it's fine with Dragonfly.

But if you are using the built-in rails caching, Carrierwave will perform better, as the files can be loaded without any processing. If you don't do any processing, it doesn't matter.

Here's how I summarized when considering both for Images on a project with Mongomapper:

Carrierwave:

  • Pros
    • Generates thumbs on upload (saves CPU time)
    • Can use files directly from a static/cached document
    • Doesn't need any cache-front
    • Supports various storage backends (S3, Cloudfiles, GridFS, normal files) easy to extend to new storage types if needed.
  • Cons
    • Generates thumbs on upload (diffucult to generate new thumbsizes)
    • Doesn't natively support mongomapper
    • Uses storagespace for every file/thumb generated. If you use normal file storage, you might run out of inodes!

Dragonfly:

  • Pros
    • Should work with mongomapper, as it only extends ActiveModel
    • Generates thumbs on the fly (easier to create new layouts/thumbsizes)
    • Only one file stored! Saves space :)
  • Cons
    • Eats CPU on every request if you don't have a cache-proxy, rack::cache or similar.
    • No way to access thumbs as files if needed.

I ended up using both in the end.

A future wish is for carrierwave to suppert MongoMapper again. After using both in various situations, I've found that the features in MongoMapper (rails3 branch) always works, and are easy to extend using plugins. Cannot say the same for Mongoid as of now, but that might change.

like image 77
leifcr Avatar answered Oct 06 '22 23:10

leifcr


I use dragonfly simply because carrierwave dropped support for mongomapper and paperclip doesn't work mongomapper without some hacks.

Dragonfly does processing on the fly, i.e.

is meant to be used behind a cache-proxy such as Varnish, Squid or Rack::Cache, so that while the first request may take some time, subsequent requests should be super-quick!

like image 25
sent-hil Avatar answered Oct 07 '22 01:10

sent-hil