将文件存储在磁盘或MongoDB上 [英] Store files on disk or MongoDB

查看:140
本文介绍了将文件存储在磁盘或MongoDB上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个mongodb / nodejs博客系统(类似于wordpress)。

我现在把图像保存在磁盘上,一个指针放在mongo 。我想知道,因为我已经将所有会话存储在MongoDB中,以实现跨服务器的轻松负载平衡,将实际文件存储在Mongo中也是一个聪明的想法,可以简化多服务器设置和/或提高性能。



如果一切都存储在数据库中,您可以简单地产生更多的Web服务器和/或mongo复制水平伸缩



意见?

解决方案MongoDB是存储文件的好选择(我正在谈论GridFS),特别是针对上述用例。
当你将文件存储到MongoDB(GridFS,而不是文档)时,你可以免费获得所有的复制和分片功能,这非常棒。

如果你有产生一个新的服务器,你已经在MongoDB中的文件,所有你需要做的是启用复制(水平伸缩)。我相信这可以为您节省很多头痛。

资源:

GridFS足够快速和可靠的生产?

http://www.mongodb.org/display/DOCS/GridFS >
http:// www。 $ c

I am creating a mongodb/nodejs blogging system (similar to wordpress).

I currently have the images being saved on the disk and a pointer being placed in mongo. I was wondering since I have all sessions being stored in MongoDB to enable easy load balancing across servers, would storing the actual files in Mongo also be a smart idea for easy multiserver setups and/or performance gains.

If everything is stored in a DB, you can simply spawn more web servers and/or mongo replications to scale horizontally

Opinions?

解决方案

MongoDB is a good option to store your files (I'm talking about GridFS), specially for the use case you described above. When you store files into MongoDB (GridFS, not documents), you get all the replication and sharding capability for free, which is awesome.

If you have to spawn a new server and you have the files already into MongoDB, all you have to do is to enable replication (thus scale horizontally). I'm sure this can save you a lot of headaches.

Resources:

Is GridFS fast and reliable enough for production?
http://www.mongodb.org/display/DOCS/GridFS
http://www.coffeepowered.net/2010/02/17/serving-files-out-of-gridfs/

这篇关于将文件存储在磁盘或MongoDB上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆