【问题标题】:Cassandra v. 3, write performance issueCassandra v. 3,写入性能问题
【发布时间】:2016-04-14 02:11:59
【问题描述】:

我遇到了 Cassandra 3 的写入性能问题。

我正在使用此处的官方 Docker 映像试用 Cassandra 3.3:https://github.com/docker-library/cassandra

我是这样开始的:

docker run --net=host --rm cassandra:3.3

然后对它运行 cassandra-stress:

cassandra-stress write

这给了我以下四个线程执行流量的结果:

op rate                   : 1913 [WRITE:1913]
partition rate            : 1913 [WRITE:1913]
row rate                  : 1913 [WRITE:1913]
latency mean              : 2.1 [WRITE:2.1]
latency median            : 1.6 [WRITE:1.6]
latency 95th percentile   : 4.1 [WRITE:4.1]
latency 99th percentile   : 8.4 [WRITE:8.4]
latency 99.9th percentile : 20.5 [WRITE:20.5]
latency max               : 155.4 [WRITE:155.4]
Total partitions          : 154607 [WRITE:154607]
Total errors              : 0 [WRITE:0]
total gc count            : 13
total gc mb               : 1951
total gc time (s)         : 1
avg gc time(ms)           : 59
stdev gc time(ms)         : 28
Total operation time      : 00:01:20

使用官方镜像为 Cassandra 2.2 做同样的事情:

docker run --net=host --rm cassandra:2.2

用四个线程给我以下结果:

op rate                   : 2248 [WRITE:2248]
partition rate            : 2248 [WRITE:2248]
row rate                  : 2248 [WRITE:2248]
latency mean              : 1.8 [WRITE:1.8]
latency median            : 1.4 [WRITE:1.4]
latency 95th percentile   : 3.5 [WRITE:3.5]
latency 99th percentile   : 7.2 [WRITE:7.2]
latency 99.9th percentile : 16.4 [WRITE:16.4]
latency max               : 129.5 [WRITE:129.5]
Total partitions          : 195461 [WRITE:195461]
Total errors              : 0 [WRITE:0]
total gc count            : 11
total gc mb               : 1612
total gc time (s)         : 1
avg gc time(ms)           : 62
stdev gc time(ms)         : 21
Total operation time      : 00:01:26

与 2.2 相比,3.3 的每秒写入次数几乎降低了 15%。这可能是什么原因?我一直在尝试更改各种参数,包括在上面的 Oracle(与 OpenJDK 相比)上运行 Cassandra,但没有显着差异。我还尝试了不同版本的 Cassandra 3,但没有发现真正的区别。我知道这是一个单一的节点,这个基本测试的结果不能转移到生产环境中。不过,我很想知道是否有人有解释或可以重现这种行为。

欢迎任何意见!

2016-04-13更新,JVM参数差异:

diff jvm-param22-sorted jvm-param33-sorted

> -XX:+AlwaysPreTouch
# Before removing this from the 3.3 config:
# USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
# cassand+     1 19.0 30.3 2876304 1229136 ?     Ssl  04:18   0:17 java
#
# After removing it:
# USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
# cassand+   177 17.0  9.4 2885596 383972 ?      Sl+  04:59   0:17 java -
#
# The above could actually explain some of the issues that I've observed in 
# low memory environments with multiple containers running since I guess it
# means Cassandra will grab the whole heap at startup from the OS
# regardless of the actual need.    

# This was present twice in the 22 config. Should not matter.
< -XX:CMSWaitDuration=10000

# Removing this from the 3.3 config did not have any significant impact
> -XX:+ResizeTLAB

# Removing from the 3.3 config did not have any significant impact
> -XX:-UseBiasedLocking

# Adding this one to the 3.3 config did not have a significant impact
< -XX:+UseCondCardMark

【问题讨论】:

    标签: docker cassandra


    【解决方案1】:

    我只是回答自己以供将来参考。在我的例子中,罪魁祸首是 JVM 参数 -XX:+AlwaysPreTouch,它是在 Cassandra 3.0 版本中默认添加的。删除它会使性能恢复到 2.2 版本的水平。

    我主要在 RAM 相当有限的环境中进行试验。我还没有对更强大的硬件做过任何实验,看看这个标志在那里有什么影响。

    【讨论】:

      【解决方案2】:

      你运行了多少次测试?

      请记住,01:40 分钟的单次运行对于性能测试来说远非全面

      【讨论】:

      • 我已经多次运行上述测试。两者都具有与上述完全相同的设置以及不同版本的 Cassandra 3.X 和 JRE。在此测试中,2.2 始终优于 3.X。通常超过上述 15% 的差异。
      • 有趣,你能发布 2 cassandra.yaml 吗?两个版本的 JVM 内存设置是否相同?
      • 是的,他们可以在这里找到:gist.github.com/tobgu/29bb48cfba1eae29098a34fdf7d969e7。它们或多或少是带有一些细微调整的原始配置文件,如上面提到的 docker repo 的 entrypoint.sh 文件中所示。我看到的主要区别是在 2.2 中使用 CMS GC 与在 3.X 中使用 G1 GC。我真的不明白这如何解释这一点,但我还没有尝试使用 CMS 运行 3.X。
      • 已知使用 G1GC 会导致这种情况与少量 ram。在两者中使用完全相同的 GC 设置。
      • 似乎它们实际上都在或多或少完全相同的 GC 设置 (CMS) 下运行。我已经用我发现的 JVM 参数的差异更新了这个问题。
      猜你喜欢
      • 1970-01-01
      • 2017-06-03
      • 2016-07-12
      • 2016-11-29
      • 2012-01-14
      • 2016-02-10
      • 2011-07-22
      • 2020-01-26
      • 2017-04-23
      相关资源
      最近更新 更多