Store files on disk or MongoDB Store files on disk or MongoDB mongoose mongoose

Store files on disk or MongoDB


MongoDB is a good option to store your files (I'm talking about GridFS), specially for the use case you described above. When you store files into MongoDB (GridFS, not documents), you get all the replication and sharding capability for free, which is awesome.

If you have to spawn a new server and you have the files already into MongoDB, all you have to do is to enable replication (thus scale horizontally). I'm sure this can save you a lot of headaches.

Resources:

Is GridFS fast and reliable enough for production?
http://www.mongodb.org/display/DOCS/GridFS
http://www.coffeepowered.net/2010/02/17/serving-files-out-of-gridfs/


Aside from GridFS, you might be considering a cloud-based deployment. In that case, you might consider storing files in cloud-specific storage (Windows Azure has Blob Storage, for example). Sticking with Windows Azure for this example (since that's what I work with), you'd reference a file by its storage account URI. For example:

https://mystorageacct.blob.core.windows.net/mycontainer/myvideo.wmv

Since you'd be storing the MongoDB database itself in its own blob (and mounted as disk volume on your Linux or Windows VM), you could then choose to store your files in either the same storage account or a completely different storage account (with each storage account providing 100TB 200TB of storage).


Storing the image as document in mongodb would be a bad idea, as the resources which could have been used to send a large amount of informational data would be used for sending files.

Have a look at mongoDb file storage GridFS , that might solve your problemof storing images, and providing horizontal scalability as well.

http://www.mongodb.org/display/DOCS/GridFShttp://www.mongodb.org/display/DOCS/GridFS+Specification