gpt4 book ai didi

MongoDB作为静态文件提供者?

转载 作者:行者123 更新时间:2023-12-03 15:30:23 27 4
gpt4 key购买 nike

MongoDB是将静态文件(文件,视频)用作cdn的一个很好的选择。我正在寻找一种可靠的方法来存储大量数据(> + To),从而重复S3并管理缓存功能。
经验。

谢谢。

最佳答案

我想这个问题的答案是,因为当您使用CDN来存储静态文件时,会使服务器摆脱静态数据请求。但是,当您在文件系统和mongodb之间进行选择时,ii认为mongodb会更快,因为如果服务器上有足够的内存,mongo会将所有数据加载到内存中。

另外,我还找到了一些可以帮助您做出选择的链接:www.markus-gattol.namegroups.google.com

从文档中:

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.

关于MongoDB作为静态文件提供者?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5058180/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com