6

I need to create a storage system for files that will mostly be under 16MB but I want the benefits of GridFS like versioning, custom metadata, easy backup (with mongodump), etc. I'd say maybe 10% of my files would be over 16MB so I can't rely on storing in single documents, and I don't want to recreate the API for the benefits I'm looking for. I'm also already using a mongoDB system.

Should I use GridFS?

Josh Kim
  • 215
  • 4
  • 14
  • Hi Josh, Have you tested to see whether GridFS performs poorly with files less than 16MB compare to storing binary within the document itself? Thanks – Maziyar Apr 13 '14 at 15:36
  • @Maziyar no I never did any benchmarks, sorry. – Josh Kim Apr 14 '14 at 16:13
  • @JoshKim I ask myself the same question today? Based on your past experience what is your opinion? – Nux May 17 '19 at 19:06

2 Answers2

7

Without further details, I'd start by suggesting you read the recommendations provided here.

Given that all of your documents won't fit within the maximum document size when stored as a BSON document as BinData, I'd recommend using the gridFS system for a consistent programming and data management experience (for developers and IT). Depending on how the files are consumed, you may be able to more efficiently stream the contents of the files to clients when they are stored in GridFS by reading and writing in chunks.

WiredPrairie
  • 58,954
  • 17
  • 116
  • 143
  • From a business perspective, this seems like the logical choice. Does GridFS perform poorly with a majority of files under 16MB? – Josh Kim Jan 17 '13 at 13:36
  • There's no documentation to suggest it performs poorly with smaller documents. You might want to create a few tests to experiment. – WiredPrairie Jan 18 '13 at 01:07
  • I think an abstraction layer to manage the complexities of storing as BinData or in GridFS would be better. GridFS doesn't offer atomic update so that is one issue. – Mukul Anand Oct 23 '18 at 07:33
-1

It is recomended to store files smaller than 16 MB within single document using use the BinData data type for binary data. So, what is the problem to store files that size is under 16MB within single document and use GridFS only for files that size is exceed 16MB.

Vokinneberg
  • 1,912
  • 2
  • 18
  • 31
  • 4
    Then I have to manage my files in 2 places and create a unifying API. I also want versioning history which I would have to also create on top of storing BinData in a single document. What if I have a 15.9MB file which I then re-upload as the latest version at 16.1MB, then my file history is in 2 databases? – Josh Kim Jan 17 '13 at 13:34