Carrierwave or Dragonfly

Danish Khan picture Danish Khan · Sep 20, 2010 · Viewed 8k times · Source

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.

Answer

leifcr picture leifcr · Jan 10, 2011

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.