MongoDB as static files provider?

后端 未结 2 388
我寻月下人不归
我寻月下人不归 2021-02-04 12:38

It\'s MongoDB a good candidate to serve static files (files, video) as cdn. I searching a solid way to store big amounts of data (>+To) remplacing S3 and managing cache features

2条回答
  •  情歌与酒
    2021-02-04 13:26

    I suppose that the answer to this question is no, because when you are using a CDN to store static files you make your server free from static data requests. But when you are choosing between a file system and mongodb Ii suppose that mongodb will be faster, beacause if there is enough ram on the server, mongo will load all data to the memory.

    Also I've found some links that can help you make your 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 file systems.

    User uploaded files. When users upload files you tend to have a lot of files, and want them replicated and backed up. GridFS is a perfect place to store these as then you can manage them the same way you manage your data. You can also query by user, upload date, etc... directly in the file store, without a layer of indirection

    Files that often change. If you have certain files that change a lot - it makes sense to store them in GridFS so you can modify them in one place and all clients will get the updates. Also can be better than storing in source tree so you don't have to deploy app to update files.

    When not to use GridFS

    Few small static files. If you just have a few small files for a website (js,css,images) its probably easier just to use the file system.

    Note that if you need to update a binary object atomically, and the object is under the document size limit for your version of MongoDB (16MB for 1.8), then you might consider storing the object manually within a single document. This can be accomplished using the BSON bindata type. Check your driver's docs for details on using this type.

提交回复
热议问题