Tracing On in cassandra 是跟踪 Cassandra 所用时间的正确选择吗

Is Tracing On in cassandra the right choice to track the timetaken in Cassandra

当我尝试对 table 中的 500000 个条目执行查询时,我可以看到它在 1200 毫秒内完成,但是当我尝试使用启用的 TRACING ON 执行查询时,我可以看到它在跟踪日志中显示很长时间,比如 1850 毫秒。

所以我想确认 Cassandra 中的 TRACING ON 功能是否是跟踪执行查询所用时间的正确选择?

根据文档 https://docs.datastax.com/en/cql/3.3/cql/cql_reference/cqlshTracing.html

Enables and disables tracing for transactions on all nodes in the cluster. Use tracing to troubleshoot performance problems. Detailed transaction information related Cassandra internal operations is captured in the system_traces keyspace. When a query runs a session id displays in the query results and an entry with the high-level details such as session id and client, and session length, is written to the system_traces.session table.

所以它应该用于性能故障排除,从而测量所花费的时间。

跟踪信息包括 activity、activity 发生的时间戳、activity 的来源和自请求开始以来经过的时间 (source_elapsed). source_elapsed 以微秒为单位。

有一些指标可以告诉您花在查询上的时间量,您可以使用 nodetool proxyhistograms (doc) 或直接从 JMX 中轻松查看它。 TRACING ON 用于调试 为什么 请求很慢。重要的是要注意,这 非常 昂贵(并且可能会增加查询时间,尽管大多数跟踪是异步的)并且应该在调试问题之外避免。

您还可以使用 nodetool settraceprobability 全局记录部分查询,然后您可以查看这些查询,并可能使用一些工具处理 system_traces 中的事件和会话 table ]键空间。