MongoDB 与 Redis

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12812502/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 15:56:53  来源:igfitidea点击:

MongoDB v/s Redis

mongodbredis

提问by Pradeep Banavara

Primary requirements:

主要要求:

  1. Clustering and replication support and hence easy and low cost deployment in cloud.
  2. Direct support for objects. Take out ORM from the equation.
  3. Python client.
  4. Read heavy and moderate writes.
  5. Need moderate speed but nothing like stock trading.
  1. 集群和复制支持,因此在云中部署简单且成本低。
  2. 直接支持对象。从等式中取出 ORM。
  3. Python客户端。
  4. 阅读重度和中度的写作。
  5. 需要中等速度,但不像股票交易那样。

回答by Pradeep Banavara

Based on this article

基于这篇文章

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

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

I finally drilled down my database choices to Redisand MongoDBas they seem to satisfy most of the requirements. I'll explain how I'm choosing the most appropriate one for my requirements.

我最终将我的数据库选择深入到RedisMongoDB,因为它们似乎满足了大部分要求。我将解释我是如何选择最适合我的要求的。

  1. Clustering and replication support - Redis has little no support for clustering or replication. Hence your memory grows in proportion to your data. Since we are using a cloud based infrastructure - the costs could be substantial in supporting that kind of a memory. MongoDB on the other hand supports replication and clustering. Redis 0 MongoDB 1.
  2. Direct support for objects - No ORM : Here clearly Redis is a winner as it supports a memcached like model. However, MongoDB also offers an 'object like storage' and direct support for JSON. So if I could sacrifice the speed requirements MongoDB does satisfy this need. Redis 1 MongoDB 1.
  3. Python client - both the databases have robust python clients. Redis 1 MongoDb 1.
  4. Read heavy and moderate writes - I don't think there is a distinctive difference in read performance against both these dbs. However only experience will say. For the time being - I'm giving equal scoring for both. Redis 1 MongoDB 1.
  5. Don't need stock trading like speed - Clearly MongoDB has an edge here. Redis 0 MongoDB 1.
  1. 集群和复制支持 - Redis 几乎不支持集群或复制。因此,您的内存与您的数据成比例增长。由于我们使用的是基于云的基础设施——支持这种内存的成本可能很高。另一方面,MongoDB 支持复制和集群。Redis 0 MongoDB 1。
  2. 对对象的直接支持 - 无 ORM:这里很明显 Redis 是赢家,因为它支持类似 memcached 的模型。然而,MongoDB 也提供了“像存储这样的对象”和对 JSON 的直接支持。因此,如果我可以牺牲速度要求,MongoDB 确实可以满足这种需求。Redis 1 MongoDB 1.
  3. Python 客户端 - 两个数据库都有强大的 Python 客户端。Redis 1 MongoDb 1。
  4. 读取重度和中度写入 - 我认为这两个数据库的读取性能没有明显差异。然而,只有经验会说。就目前而言 - 我对两者给予同等的评分。Redis 1 MongoDB 1.
  5. 不需要像速度那样的股票交易 - 显然 MongoDB 在这里有优势。Redis 0 MongoDB 1。

Total score : Redis 3 MongoDB 5.

总分:Redis 3 MongoDB 5。

For now I'm gonna go with MongoDB. As an added bonus MongoDB also has geospatial query support. So if for whatever reason I have to add location based querying to my app, it shouldn't be really hard to make that transition with MongoDB. Let's see how things map out. I hope to come back some day and revisit this answer :). Please feel free to add anything that I've missed.

现在我要使用 MongoDB。作为额外的奖励,MongoDB 还具有地理空间查询支持。因此,如果出于某种原因我必须将基于位置的查询添加到我的应用程序中,那么使用 MongoDB 进行这种转换应该并不难。让我们看看事情是如何发展的。我希望有一天能回来并重新审视这个答案:)。请随意添加我遗漏的任何内容。