我想要的不是Redis和MongoDB之间的比较。我知道它们是不同的;性能和API是完全不同的。

Redis非常快,但是API非常“原子化”。MongoDB会消耗更多的资源,但是API非常非常容易使用,我对它非常满意。

它们都很棒,我想在部署中尽可能多地使用Redis,但很难编写代码。我想在开发中尽可能多地使用MongoDB,但它需要一台昂贵的机器。

那么你认为两者的作用是什么呢?什么时候选择Redis?什么时候选择MongoDB?


当前回答

我想说的是,这取决于你所在的开发团队以及你的应用程序需求。

For example, if you require a lot of querying, that mostly means it would be more work for your developers to use Redis, where your data might be stored in variety of specialized data structures, customized for each type of object for efficiency. In MongoDB the same queries might be easier because the structure is more consistent across your data. On the other hand, in Redis, sheer speed of the response to those queries is the payoff for the extra work of dealing with the variety of structures your data might be stored with.

MongoDB为具有传统DB和SQL经验的开发人员提供了简单、更短的学习曲线。然而,Redis的非传统方法需要更多的努力去学习,但更大的灵活性。

如。缓存层可能在Redis中可以更好地实现。对于更多可模式的数据,MongoDB更好。[注:MongoDB和Redis在技术上都是无模式的]

如果你问我,我个人对大多数需求的选择是Redis。

最后,我希望你现在已经看到http://antirez.com/post/MongoDB-and-Redis.html

其他回答

也许这个资源可以帮助你在两者之间做出选择。 它还讨论了其他几个NoSQL数据库,并提供了一个简短的特征列表,以及对每个数据库的“我将使用它做什么”的解释。

http://kkovacs.eu/cassandra-vs-mongodb-vs-couchdb-vs-redis

我想说的是,这取决于你所在的开发团队以及你的应用程序需求。

For example, if you require a lot of querying, that mostly means it would be more work for your developers to use Redis, where your data might be stored in variety of specialized data structures, customized for each type of object for efficiency. In MongoDB the same queries might be easier because the structure is more consistent across your data. On the other hand, in Redis, sheer speed of the response to those queries is the payoff for the extra work of dealing with the variety of structures your data might be stored with.

MongoDB为具有传统DB和SQL经验的开发人员提供了简单、更短的学习曲线。然而,Redis的非传统方法需要更多的努力去学习,但更大的灵活性。

如。缓存层可能在Redis中可以更好地实现。对于更多可模式的数据,MongoDB更好。[注:MongoDB和Redis在技术上都是无模式的]

如果你问我,我个人对大多数需求的选择是Redis。

最后,我希望你现在已经看到http://antirez.com/post/MongoDB-and-Redis.html

很难回答的问题——和大多数技术解决方案一样,这真的取决于你的情况,因为你没有描述你正在试图解决的问题,谁能提出解决方案呢?

您需要对它们进行测试,以确定其中哪一个满足您的需求。

也就是说,MongoDB不需要任何昂贵的硬件。与任何其他数据库解决方案一样,它需要更多的CPU和内存才能更好地工作,但肯定不是必需的——特别是对于早期开发目的。

如果你有足够的RAM,你应该使用这两种方法。Redis和MongoDB达到了通用工具的价格。这会带来很多开销。

有一种说法是Redis比Mongo快10倍。这可能不再是真的了。MongoDB(如果我没记错的话)声称只要内存配置相同,就可以在存储和缓存文档方面击败memcache。

不管怎样。Redis不错,MongoDB也不错。如果你关心子结构并且需要聚合,那么就选择MongoDB。如果存储键和值是你主要关心的,它都是关于Redis。(或任何其他键值存储)。

如果你的项目预算允许你有足够的RAM内存在你的环境-答案是Redis。尤其是考虑到新的Redis 3.2的集群功能。