We often get asked “Should I use GridFS for file storage with MongoDB”. As with most things, the answer is a staunch “it depends”.
GridFS looks like a great idea on paper – a virtual filesystem held within MongoDB which allows for larger than 16MB files to be held, synced and replicated. It’s very tempting when architecting your solutions to want to consider using GridFS. It appears to be able to take on the problem of storing many thousands or millions of files without consuming file-system resources where there are often hard limits on the number of file names. It also seems to allow for massive files to be stored without any obvious downsides.
It is important, though, to know what GridFS is under the hood. For any file being stored with GridFS, the file is chopped into 255KB chunks. Those chunks are saved in a bucket, called fs, and a collection in that bucket, fs.chunks. Metadata about the files is stored in another collection in the same bucket, fs.files, though you can have more buckets with different bucket names in the same database. An index makes retrieving the chunks quick. All this chunking and metadata management is not done by the MongoDB database though. It is a task performed by the client’s driver which is then wrapped in a GridFS API for that driver.
Source: Open Source