【问题标题】:Cassandra and row cacheCassandra 和行缓存
【发布时间】:2017-01-29 21:54:22
【问题描述】:

我想在 Cassandra 中使用行缓存,但我不明白它是如何工作的。 我在 cassandra.yaml 中启用了行缓存(2GB 分配)并更改了架构:

ALTER TABLE d
with caching = {
    'keys' : 'ALL',
    'rows_per_partition' : '36000'
};

键缓存工作正常,我的命中率为 90%,而对于行缓存,我从 nodetool info 看到这些数字:

Row Cache : entries 2, size 2 bytes, capacity 1.95 GB, 1620 hits, 39699640 requests, 0.000 recent hit rate, 0 save period in seconds

如您所见,缓存仅包含 2 个条目,而我对该表上的所有条目执行了 4M+ 查询。

有什么想法吗?我应该调查什么来了解为什么不使用行缓存?

更新 1 感谢 Chris,我已经使用 row_cache_save_period = 14400 重新配置了集群。但我没有看到任何变化。

Row Cache : entries 0, size 0 bytes, capacity 1.95 GB, 0 hits, 85098 requests, 0.000 recent hit rate, 14400 save period in seconds

更新 2 这是架构定义:

CREATE TABLE d_t (
    id bigint,
    xid bigint,
    ts timestamp,
    avg double,
    ce double,
    cg double,
    p double,
    w double,
    c double,
    sum double,
    last double,
    max double,
    min double,
    p75 double,
    p90 double,
    p95 double,
    squad double,
    sumq double,
    wavg double,
    weight double,
    PRIMARY KEY ((id), xid, ts)
) WITH CLUSTERING ORDER BY (xid DESC, ts DESC)
and  compaction = {'class': 'SizeTieredCompactionStrategy'} 
and gc_grace_seconds=86400
and caching = { 'keys' : 'ALL', 'rows_per_partition':'36000' }
and min_index_interval = 2
and max_index_interval = 20;

更新 3

使用 Cassandra 3.0.9

【问题讨论】:

    标签: cassandra


    【解决方案1】:

    您设置了row_cache_size_in_mb 选项。您还需要将row_cache_save_period 设置为0(默认)。这会禁用它。这显示在消息的0 save period in seconds 部分。

    【讨论】:

    • 谢谢。我已经更改了该参数并重新启动了集群,但仍然是相同的行为。 '行缓存:条目 0,大小 0 字节,容量 1.95 GB,0 次命中,85098 个请求,0.000 最近命中率,14400 秒保存周期ì
    • 您能否包含您的架构和版本?您可能会遇到一些问题,例如issues.apache.org/jira/browse/CASSANDRA-12499
    • 添加了架构定义。谢谢。使用 cassandra 3.0.9
    • 你有机会看吗?谢谢!
    【解决方案2】:

    我明白了。分享给其他用户。 3.0.x 行缓存实现中存在一些错误,最有问题的一点是“clustering order by”子句。删除 order by 后,行缓存开始工作。我已经在 3.9 上对此进行了测试。 但是,如果 where 条件仅包含分区键,则使用行缓存。如果指定了集群列上的过滤器,则不会评估缓存。 这真的很奇怪,但仅此而已。这里有更多细节:https://issues.apache.org/jira/browse/CASSANDRA-8646

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-02-14
      • 2014-09-24
      • 1970-01-01
      • 1970-01-01
      • 2012-10-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多