MongoDB 作为静态文件提供者?

发布于 2024-10-18 10:00:48 字数 103 浏览 1 评论 0原文

MongoDB 是作为 CDN 提供静态文件(文件、视频)的良好候选者。我正在寻找一种可靠的方法来存储大量数据(>+To)来取代 S3 并管理缓存功能。 经验。

谢谢。

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.
Experiences.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时光与爱终年不遇 2024-10-25 10:00:48

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

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

来自文档:

何时使用 GridFS

很多文件。 GridFS 倾向于处理大量数据(数千)
的文件比许多文件好
系统。

用户上传的文件。当用户上传文件时,您往往会有很多
文件,并希望它们被复制并
已备份。 GridFS 是一个完美的地方
存储这些,以便您可以管理
他们就像你管理你的一样
数据。您还可以按用户查询,
上传日期等...直接在
文件存储,无层
间接

经常更改的文件。如果您的某些文件变化很大 -
将它们存储在 GridFS 中是有意义的
这样你就可以在一处修改它们
所有客户都会收到更新。
也可以比存储更好
源树所以你不必
部署应用程序来更新文件。

何时不使用 GridFS

一些小的静态文件。如果您只有几个小文件
网站(js、css、图像)可能是
使用文件系统更容易。

请注意,如果您需要原子地更新二进制对象,并且
对象低于文档尺寸
您的 MongoDB 版本的限制
(1.8 为 16MB),那么您可能
考虑手动存储对象
在单个文档中。这可以是
使用 BSON bindata 完成
类型。检查您的驱动程序文档
有关使用此类型的详细信息。

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.

じ违心 2024-10-25 10:00:48

一般来说,答案是肯定的,您可以使用 mongodb 来执行此操作,但 mongodb 没有像 apache/random-webserver 那样提供文件服务的 http 接口。例如,如果您需要添加其他功能,例如这些文件的应用程序身份验证,那么它可能更有意义。

您可以围绕 mongodb 创建一个基础架构,在其中复制更改并编写一个 http 前端来提供文件服务(例如 nginx-gridfs 或任何其他 gridfs http 组件)。但您需要构建/集成这些、测试并部署它们。使用带有标准 Web 服务器的文件系统来提供文件已经过充分的测试和记录;许多系统使用 rsync 来有效地将文件复制到许多节点。

CDN 做了很多事情,您必须重新实现,自己解决所有这些事情可能没有意义,但这确实是另一个问题。

Generally the answer would be yes, you can use mongodb to do this but mongodb does not have an http interface to serve files like apache/random-webserver does. If you need to add additional feature, like application authentication for those files then it might make more sense, as an example.

You can create an infrastructure around mongodb where you replicate changes and write a http front-end to serve files (like nginx-gridfs or any of the other gridfs http components). But you would need to build/integrate these, test and deploy it all. Using a file-system with a standard web-server to provide the files is very well tested and documented; many systems use rsync to efficiently replicate files to many nodes.

There are so many things that a cdn does that you would have to re-implement it might not make sense to tackle all of that yourself, but that is really another question.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文