何时用 NoSQL 替换 RDBMS/ORM [英] When to replace RDBMS/ORM with NoSQL

查看:43
本文介绍了何时用 NoSQL 替换 RDBMS/ORM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 NoSQL 数据库而不是 ORM 包装的 rdbms 对哪些项目有好处?

What kind of projects benefit from using a NoSQL database instead of rdbms wrapped by an ORM?

示例:

  • Stackoverflow 类似的网站?
  • 社交社区?
  • 论坛?

推荐答案

你的问题很笼统.NoSQL 描述了一组彼此非常不同的数据库技术.大致有:

Your question is very general. NoSQL describes a collection of database techniques that are very different from each other. Roughly, there are:

  • 键值存储(Redis、Riak)
  • Triplestores (AllegroGraph)
  • 列式商店(Bigtable、Cassandra)
  • 面向文档的存储(CouchDB、MongoDB)
  • 图形数据库 (Neo4j)

在项目的开发阶段使用文档数据库可以使项目受益,因为您不必设计复杂的实体关系图或编写复杂的连接查询.我在 这个答案中详细介绍了文档数据库的其他用途.

A project can benefit from the use of a document database during the development phase of the project, because you won't have to design complex entity-relation diagrams or write complex join queries. I've detailed other uses of document databases in this answer.

如果您的应用程序需要处理大量数据,那么当您使用专门的 NoSQL 解决方案(例如 Cassandra)时,开发阶段可能会更长.但是,当您的应用进入生产时,它将极大地受益于 Cassandra 的性能和可扩展性.

If your application needs to handle very large amounts of data, the development phase will likely be longer when you use a specialized NoSQL solution such as Cassandra. However, when your application goes into production, it will greatly benefit from the performance and scalability of Cassandra.

一般来说,如果一个应用有以下要求:

Very generally speaking, if an application has the following requirements:

  • 水平缩放
  • 使用数据模型 X
  • 执行 Y 操作

应用程序将受益于使用 NoSQL 解决方案,该解决方案旨在存储数据模型 X 并对数据执行 Y 操作.如果您需要关于某种类型的 NoSQL 数据库的更具体的答案,您需要更新您的问题.

the application will benefit from using a NoSQL solution that is geared towards storing data model X and perform Y operations on the data. If you need more specific answers regarding a certain type of NoSQL database, you'll need to update your question.

  1. 开发过程中的好处(例如,比 SQL 更易于使用,没有许可成本)?
  2. 性能方面的优势(例如,在拥有 100 万并发用户的情况下像地狱一样运行)?
  3. 什么类型的 NoSQL 数据库?

<小时>

更新

键值存储在大多数情况下只能通过键进行查询.它们对于存储简单数据很有用,例如用户会话、简单的配置文件数据或预先计算的值和输出.尽管可以在键值对中存储更复杂的数据,但它会加重应用程序维护手动"索引以执行更高级查询的责任.


Update

Key-value stores can only be queried by key in most cases. They're useful to store simple data, such as user sessions, simple profile data or precomputed values and output. Although it is possible to store more complex data in key-value pairs, it burdens the application with the responsibility of maintaining 'manual' indexes in order to perform more advanced queries.

Triplestores 用于存储资源描述元数据.我对这些商店一无所知,除了维基百科告诉我的内容,所以你会必须对此进行一些研究.

Triplestores are for storing Resource Description Metadata. I don't anything about these stores, except for what Wikipedia tells me, so you'll have to do some research on that.

列族存储专为存储和处理大量数据而构建.它们被 Google 的搜索引擎和 Facebook 的收件箱搜索使用.数据由MapReduce 函数查询.尽管 MapReduce 函数一开始可能难以掌握,但其概念非常简单.这是一个类比,(希望)解释了这个概念:

Column-family stores are built for storing and processing very large amounts of data. They are used by Google's search engine and Facebook's inbox search. The data is queried by MapReduce functions. Although MapReduce functions may be hard to grasp in the beginning, the concept is quite simple. Here's an analogy which (hopefully) explains the concept:

假设您有多个装满收据的鞋盒,并且您想计算总费用.你邀请你的一些朋友过来,并为每个鞋盒分配一个人.每个人在他的鞋盒里写下每张收据的总数.这个选择所需数据的过程就是Map部分.

Imagine you have multiple shoe-boxes filled with receipts, and you want to calculate your total expenses. You invite some of your friends over and assign a person to each shoe-box. Each person writes down the total of each receipt in his shoe-box. This process of selecting the required data is the Map part.

当一个人写下他的(部分)收据的总数时,他可以总结这些总数.这是减少部分,可以重复多次,直到处理完所有收据.最后,你所有的朋友聚集在一起,总结他们的总和,给你你的总费用.这是最后的 Reduce 步骤.

When a person has written down the totals of (some of) his receipts, he can sum up these totals. This is the Reduce part and can be repeated multiple times until all receipts have been handled. In the end, all of your friends come together and sum up their total sums, giving you your total expenses. That's the final Reduce step.

这种方法的优点是您可以拥有任意数量的鞋盒,并且可以将任意数量的人分配到鞋盒中,但最终仍会得到相同的结果.每个鞋盒都可以看作是数据库网络中的一个服务器.每个朋友都可以看作是服务器上的一个线程.使用 MapReduce,您可以将数据分布在多台服务器上,并让每个服务器处理部分查询,从而优化数据库的性能.

The advantage of this approach is that you can have any number of shoe-boxes and you can assign any number of people to a shoe-box and still end up with the same result. Each shoe-box can be seen as a server in the database's network. Each friend can be seem as a thread on the server. With MapReduce you can have your data distributed across many servers and have each server handle part of the query, optimizing the performance of your database.

面向文档的存储这个问题,所以我不会在这里讨论它们.

Document-oriented stores are explained in this question, so I won't discuss them here.

图数据库用于存储高度连接对象的网络,例如社交网络上的用户.这些数据库针对图操作进行了优化,例如查找两个节点之间的最短路径,或者查找距当前节点三跳内的所有节点.此类操作在 RDBMS 系统或其他 NoSQL 数据库上非常昂贵,但在图数据库上非常便宜.

Graph databases are for storing networks of highly connected objects, like the users on a social network for example. These databases are optimized for graph operations, such as finding the shortest path between two nodes, or finding all nodes within three hops from the current node. Such operations are quite expensive on RDBMS systems or other NoSQL databases, but very cheap on graph databases.

这篇关于何时用 NoSQL 替换 RDBMS/ORM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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