卡桑德拉截断性能 [英] Cassandra truncate performance

查看:56
本文介绍了卡桑德拉截断性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近有人告诉我,cassandra truncate不是高效能的,而是反模式.但是,我不知道为什么?

I have been recently told that, cassandra truncate is not performant and it is anti pattern. But, I do not know why?

所以,我有两个问题:

  • 对所有记录进行高位插入然后进行截断是否更有表现?

  • Is it more performant to have upsert of all records then doing truncate?

截断操作是否会创建逻辑删除?

Does truncate operation creates tombstones?

Cassandra版本:3.x

Cassandra Version: 3.x

推荐答案

来自cassandra文档:

From the cassandra docs:

注意:TRUNCATE向所有节点发送JMX命令,告诉它们从指定表中删除保存数据的SSTable.如果有这些节点关闭或不响应,命令失败并输出这样的消息

Note: TRUNCATE sends a JMX command to all nodes, telling them to delete SSTables that hold the data from the specified table. If any of these nodes is down or doesn't respond, the command fails and outputs a message like the following

因此,运行truncate将删除属于cassandra表的所有sstables,这将非常快,但必须由所有节点确认.根据您的cassandra.yml,它将在以下之前对您的数据进行快照:

So, running truncate will issue a deletion of all sstables belonging to your cassandra table, which will be quite fast but must be acknowledged by all nodes. Depending on your cassandra.yml this will snapshot your data before:

auto_snapshot (默认值:true)启用或禁用快照是否为在键空间截断或删除表之前获取的数据.至为避免数据丢失,强烈建议使用默认设置.如果设置为false时,将因截断或丢弃而丢失数据.

auto_snapshot (Default: true) Enable or disable whether a snapshot is taken of the data before keyspace truncation or dropping of tables. To prevent data loss, using the default setting is strongly advised. If you set to false, you will lose data on truncation or drop.

在创建或修改表时,您可以启用或禁用键缓存(分区键缓存)或该表的行缓存,方法是设置缓存参数.其他行和键缓存的调优和配置选项在全局(节点)级别设置.卡桑德拉使用这些设置以自动为节点上的每个表分配内存根据整体工作量和特定的表使用情况.你也可以全局配置这些缓存的保存期限.

When creating or modifying tables, you enable or disable the key cache (partition key cache) or row cache for that table by setting the caching parameter. Other row and key cache tuning and configuration options are set at the global (node) level. Cassandra uses these settings to automatically distribute memory for each table on the node based on the overall workload and specific table usage. You can also configure the save periods for these caches globally.

对您的问题:

  • upserts将慢得多(当表中有大量数据时)
  • truncate根本不写逻辑删除(相反,它将立即为截断的表sstable删除所有节点上的 all )

这篇关于卡桑德拉截断性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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