Should I store an image in MongoDB or in local File System (by Node.js) Should I store an image in MongoDB or in local File System (by Node.js) mongodb mongodb

Should I store an image in MongoDB or in local File System (by Node.js)


The most scalable solution is to use a shared storage service such as Amazon's S3 (or craft your own).

This allows you to scale horizontally a lot easier when you decide to add machines to your application layer, as you won't have to worry about any migration nightmares.

The basic idea behind this is to keep the storage layer decoupled from the application layer. So using this idea you could create a node.js process on a separate machine that accepts file uploads then writes them to disk.


If you're designing a performance sensitive system, use file system to store your images no doubt.

You can find the performance compare from this blog:http://blog.thisisfeifan.com/2013/12/mongodb-gridfs-performance-test.html

Actually, you can find the recommended MongoDB GridFS use cases here:https://docs.mongodb.com/manual/core/gridfs/#when-to-use-gridfs


I would use GridFS to take advantage of sharding but for best performance I would use filesystem with nginx.