MongoDB as a provider of static files?

This MongoDB is a good candidate for serving static files (files, videos) as cdn. I am looking for a reliable way to store large amounts of data (> + To), redistribute S3 and manage cache functions. An experience.

Thanks.

+7
mongodb amazon-s3 gridfs
source share
2 answers

I believe there is no answer to this question, because when you use CDN to store static files, you free your server from static data requests. But when you choose between the file system and mongodb, suppose mongodb is faster, beacause if there is enough ram on the server, mongo will load all the data into memory.

I also found some links that can help you make a choice: www.markus-gattol.name , groups.google.com

From the documentation:

When to use GridFS

Lots of files. GridFS tends to handle large numbers (many thousands) of files better than many system files.

User uploaded files. When users upload files, you usually have a lot of files and want them to be replicated and backed up. GridFS is an ideal place to store them, as then you can manage them the way you manage your data. You can also request the user, download date, etc. Directly to the file store, without a layer of indirection

Files that change frequently. If you have certain files that change a lot, it makes sense to store them in GridFS so you can change them in one place and all clients will receive updates. It may also be better than storing in the source tree, so you do not need to deploy the application to update the files.

If you do not use GridFS

A few small static files. If you only have a few small files for the site (js, css, images), it is probably easier to just use the file system.

Please note that if you need to update a binary object atomically, and the object is under the document size restriction for your version of MongoDB (16 MB for 1.8), then you may consider storing the object manually in one document. This can be done using the BSON type binding. Check your driver's docs for details on using this type.

+10
source share

In general, the answer is yes, you can use mongodb for this, but mongodb does not have an http interface for working with files like apache / random-webserver. If you need to add an additional feature, such as application authentication for these files, then this may make more sense as an example.

You can create an infrastructure around mongodb where you replicate the changes and write an http interface for working with files (for example, nginx-gridfs or any other component of httpff gridfs). But you will need to build / integrate them, test and deploy it all. Using a file system with a standard web server to provide files is very well tested and documented; many systems use rsync to efficiently replicate files to many nodes.

There are so many things that Cdn does that you have to reprogram it, it may not make sense to solve all this yourself, but that is really a different issue.

+2
source share

All Articles