最近有很多关于卡桑德拉的话题。

Twitter, Digg, Facebook等都在使用它。

什么时候有意义:

使用卡桑德拉, 不用卡桑德拉,还有 使用RDMS而不是Cassandra。


当前回答

没有什么是银弹,任何东西都是为了解决特定的问题而构建的,有自己的优点和缺点。这取决于你,你有什么问题陈述,什么是该问题的最佳解决方案。

我会按照你问的顺序一个一个地回答你的问题。因为Cassandra是基于NoSQL数据库家族的,所以在我回答你的问题之前,理解为什么使用NoSQL数据库是很重要的。

为什么使用NoSQL

In the case of RDBMS, making a choice is quite easy because all the databases like MySQL, Oracle, MS SQL, PostgreSQL in this category offer almost the same kind of solutions oriented toward ACID properties. When it comes to NoSQL, the decision becomes difficult because every NoSQL database offers different solutions and you have to understand which one is best suited for your app/system requirements. For example, MongoDB is fit for use cases where your system demands a schema-less document store. HBase might be fit for search engines, analyzing log data, or any place where scanning huge, two-dimensional join-less tables is a requirement. Redis is built to provide In-Memory search for varieties of data structures like trees, queues, linked lists, etc and can be a good fit for making real-time leaderboards, pub-sub kind of system. Similarly there are other databases in this category (Including Cassandra) which are fit for different problem statements. Now lets move to the original questions, and answer them one by one.

何时使用卡桑德拉

Being a part of the NoSQL family, Cassandra offers a solution for problems where one of your requirements is to have a very heavy write system and you want to have a quite responsive reporting system on top of that stored data. Consider the use case of Web analytics where log data is stored for each request and you want to built an analytical platform around it to count hits per hour, by browser, by IP, etc in a real time manner. You can refer to this blog post to understand more about the use cases where Cassandra fits in.

什么时候使用RDMS而不是Cassandra

Cassandra基于NoSQL数据库,不提供ACID和关系数据属性。如果您对ACID属性有强烈的需求(例如财务数据),Cassandra将不适合这种情况。显然,您可以为此制定一个变通方案,但是您最终将编写大量的应用程序代码来模拟ACID属性,并将严重延误上市时间。同时,使用Cassandra管理这种系统对您来说也是复杂而乏味的。

什么时候不用卡桑德拉

我认为上面的解释是否有意义不需要回答。

其他回答

NoSQL的一般思想是,您应该使用最适合您的应用程序的数据存储。如果您有一个财务数据表,请使用SQL。如果您的对象需要复杂/缓慢的查询才能映射到关系模式,请使用对象或键/值存储。

当然,你遇到的任何现实问题都处于这两个极端之间,没有一个解决方案是完美的。您需要考虑每个存储的功能以及使用其中一个的后果,这将非常具体于您试图解决的问题。

除了这里的其他答案之外,沉重的单个查询与无数的轻查询负载是另一个需要考虑的问题。在nosql风格的DB中自动优化单个查询本身就比较困难。我使用过MongoDB,在尝试计算复杂查询时遇到了性能问题。我没有使用Cassandra,但我预计它会有同样的问题。

另一方面,如果您的负载预期是许多小型查询的负载,并且您希望能够轻松地向外扩展,那么您可以利用大多数NoSql数据库提供的最终一致性。注意,最终一致性实际上不是非关系数据模型的特性,但是在基于nosql的系统中实现和设置一致性要容易得多。

For a single, very heavy query, any modern RDBMS engine can do a decent job parallelizing parts of the query and take advantage of as much CPU and memory you throw at it (on a single machine). NoSql databases don't have enough information about the structure of the data to be able to make assumptions that will allow truly intelligent parallelization of a big query. They do allow you to easily scale out more servers (or cores) but once the query hits a complexity level you are basically forced to split it apart manually to parts that the NoSql engine knows how to deal with intelligently.

根据我使用MongoDB的经验,由于查询的复杂性,MongoDB最终无法对其进行优化,也无法在多个数据上运行部分查询。Mongo可以并行多个查询,但不太擅长优化单个查询。

让我们来读一些真实的案例:

http://planetcassandra.org/apache-cassandra-use-cases/

本文地址:http://planetcassandra.org/blog/post/agentis-energy-stores-over-15-billion-records-of-time-series-usage-data-in-apache-cassandra

他们详细阐述了不选择MySql的原因,因为数据库同步太慢。

(也是由于2- phase commit, FK, PK)


Cassandra基于Amazon Dynamo纸

特点:

稳定

高可用性

备份性能良好

读写比HBase好,(java中的BigTable克隆)。

wiki http://en.wikipedia.org/wiki/Apache_Cassandra

他们的结论是:

We looked at HBase, Dynamo, Mongo and Cassandra. 

Cassandra was simply the best storage solution for the majority of our data.

截至2018年,

如果你需要支援,我建议你用ScyllaDB代替经典的cassandra。

Postgres kv插件也比cassandra快。无论如何不会有多实例可伸缩性。

在评估分布式数据系统时,您必须考虑CAP定理——您可以选择以下两个:一致性、可用性和分区容差。

Cassandra是一个可用的、支持最终一致性的分区容忍系统。要了解更多信息,请参阅我写的这篇博客文章:NoSQL系统的可视化指南。

根据DataStax,当需要Cassandra时,它并不是最好的用例

1-高端硬件设备。 2- ACID兼容,无回滚(银行交易)