最近有很多关于卡桑德拉的话题。
Twitter, Digg, Facebook等都在使用它。
什么时候有意义:
使用卡桑德拉, 不用卡桑德拉,还有 使用RDMS而不是Cassandra。
最近有很多关于卡桑德拉的话题。
Twitter, Digg, Facebook等都在使用它。
什么时候有意义:
使用卡桑德拉, 不用卡桑德拉,还有 使用RDMS而不是Cassandra。
当前回答
在这里,我将重点介绍一些重要的方面,这些方面可以帮助你决定是否真的需要卡桑德拉。这个清单并不详尽,只是我脑海中最重要的一些观点
Don't consider Cassandra as the first choice when you have a strict requirement on the relationship (across your dataset). Cassandra by default is AP system (of CAP). But, it supports tunable consistency which means it can be configured to support as CP as well. So don't ignore it just because you read somewhere that it's AP and you are looking for CP systems. Cassandra is more accurately termed “tuneably consistent,” which means it allows you to easily decide the level of consistency you require, in balance with the level of availability. Don't use Cassandra if your scale is not much or if you can deal with a non-distributed DB. Think harder if your team thinks that all your problems will be solved if you use distributed DBs like Cassandra. To start with these DBs is very simple as it comes with many defaults but optimizing and mastering it for solving a specific problem would require a good (if not a lot) amount of engineering effort. Cassandra is column-oriented but at the same time each row also has a unique key. So, it might be helpful to think of it as an indexed, row-oriented store. You can even use it as a document store. Cassandra doesn't force you to define the fields beforehand. So, if you are in a startup mode or your features are evolving (as in agile) - Cassandra embraces it. So better, first think about queries and then think about data to answer them. Cassandra is optimized for really high throughput on writes. If your use case is read-heavy (like cache) then Cassandra might not be an ideal choice.
其他回答
让我们来读一些真实的案例:
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快。无论如何不会有多实例可伸缩性。
another situation that makes the choice easier is when you want to use aggregate function like sum, min, max, etcetera and complex queries (like in the financial system mentioned above) then a relational database is probably more convenient then a nosql database since both are not possible on a nosql databse unless you use really a lot of Inverted indexes. When you do use nosql you would have to do the aggregate functions in code or store them seperatly in its own columnfamily but this makes it all quite complex and reduces the performance that you gained by using nosql.
Right. It makes sense to use Cassandra when you have a huge amount of data, a huge number of queries but very little variety of queries. Cassandra basically works by partitioning and replicating. If all your queries will be based on the same partition key, Cassandra is your best bet. If you get a query on an attribute that is not the partition key, Cassandra allows you to replicate the whole data with a new partition key. So now you have 2 replicas of the same data with 2 different partition keys.
这就引出了你的下一个问题。什么时候不用卡桑德拉。正如我提到的,Cassandra通过为每个新的分区键复制完整的数据库来扩展。但你不能一遍又一遍地复制。因此,当你有大量的查询,即每个查询在where子句中有不同的列时,Cassandra不是一个好的选择。
现在是第三个问题。使用RDBMS的关键在于需要ACID属性。如果您正在构建类似于支付服务的东西,并且希望每个交易都是隔离的,每个交易要么完成要么根本不发生,即使系统出现故障,更改仍然是持久的,并且在交易完成之前和之后各银行账户的资金是一致的,那么RDBMS是帮助您实现这一目标的唯一选择。
这篇文章实际上解释了整个事情,特别是什么时候使用Cassandra或不使用(相对于其他一些NoSQL选项)问题的一部分——>选择最好的数据库。一定要去看看。
编辑:为了回答proximab评论中的问题,当我们想到银行系统时,我们立即认为“ACID是最好的解决方案”。但即使是银行系统也由几个子系统组成,这些子系统甚至可能不处理任何与交易相关的数据,如账户持有人的个人信息、账户对账单、信用卡详细信息、信用历史等。
All of this information needs to be stored in some database or the another. Now if you store the account related information like account balance, that is something that needs to be consistent at all times. For example, if you try to send money from account A to account B, then the money that disappears from account A should instantaneousy show up in account B, and it cannot be present in both accounts at the same time. This system cannot be inconsistant at any point. This is where ACID is of utmost importance.
另一方面,如果您正在保存信用卡详细信息或信用记录,不应该落入坏人之手,那么您需要一些只允许授权用户访问的东西。我相信这是卡桑德拉支持的。也就是说,像信用记录和信用卡交易这样的数据,我认为这是一个不断增长的数据。此外,你可以查询的数据也只有这么多,即它有非常有限的查询数量。这两个条件使Cassandra成为一个完美的解决方案。
根据DataStax,当需要Cassandra时,它并不是最好的用例
1-高端硬件设备。 2- ACID兼容,无回滚(银行交易)
如果你需要一个SQL语义完全一致的数据库,Cassandra不是你的解决方案。Cassandra支持键值查找。它不支持SQL查询。Cassandra中的数据“最终是一致的”。数据的并发查找可能不一致,但最终查找是一致的。
如果你需要严格的语义,需要对SQL查询的支持,可以选择其他的解决方案,比如MySQL, PostGres,或者结合使用Cassandra和Solr。