Is GridFS faster than usual FS?

In general it's slower for usual filesystem access style. But it can benefit from nice MongoDB features:

  • You can associate any metadata with the files and query it in a usual manner. Actually files are stored as regular Mongo documents in fs.files and fs.chunks collections.
  • Replication. With a replica set you will get an (almost) instant backup, failover and read scalability (read request can go to slave nodes).
  • Sharding. Like any other collection it's possible to distribute files across multiple Mongo instances with auto-sharding. This will improve write scalability.

When to use GridFS

  • If your filesystem limits the number of files in a directory, you can use GridFS to store as many files as needed.
  • When you want to keep your files and metadata automatically synced and deployed across a number of systems and facilities. When using geographically distributed replica sets MongoDB can distribute files and their metadata automatically to a number of mongod instances and facilitates.
  • When you want to access information from portions of large files without having to load whole files into memory, you can use GridFS to recall sections of files without reading the entire file into memory.

Tags:

Mongodb

Gridfs