卡桑德拉(Cassandra)阅读表现的位置

发布于 2025-02-08 19:36:05 字数 1840 浏览 2 评论 0原文

我有一个Cassandra簇,有6个节点,每个节点有96个CPU/800 RAM。

我的性能测试表是:

create table if not exists space.table
(
    id          bigint primary key,
    data        frozen<list<float>>,
    updated_at  timestamp
);

表包含150.000.000行。

当我使用查询测试时:

SELECT * FROM space.table WHERE id = X

我什至无法超载群集,客户端本身被超载,RPS到群集为350.000。

现在,我正在测试第二个测试用例:

SELECT * FROM space.table WHERE id in (X1, X2 ... X3000)

我想根据请求从Cassandra中获取3000行。

在这种情况下,Max RPP 15 RPS 之后,在Cassandra线程池中发生了许多待处理任务,其中包括: native-transport-requests 。 从Cassandra获得大结果集不是最好的主意吗?最好的做法是什么,可以肯定的是,我可以将3000行分开以分开请求,例如30个请求每个请求,每个请求100个ID。 我在哪里可以找到有关它的信息,也许从性能的角度来看,运营不好?

更新:

想分享我的测量结果,以从卡桑德拉(Cassandra)乘以不同的块大小来获得3000行的测量值:

 每个请求使用3000 ID测试

延迟:5秒
Max RPS到Cassandra:20


每个请求使用100个ID测试(总计300个请求按100个IDS)
350 RPS服务的延迟(350 * 30 = 10500请求Cassandra):170 ms(Q99),95 ms(Q90),75 ms(Q50)
Max RPS到Cassandra:350 * 30 = 10500

每个请求使用20个ID测试(总计150个请求按20个IDS) 
服务的延迟250 RPS服务(250 * 150 = 37500请求Cassandra):49 MS(Q99),46 MS(Q90),32 MS(Q50)
服务的延迟在600 RPS服务(600 * 150 = 90000请求Cassandra):190 ms(Q99),180 ms(Q90),148 ms(Q50)
Max RPS到Cassandra:650 * 150 = 97500


每个请求使用10个ID测试(总计300个请求通过10个IDS)
服务延迟250 RPS服务(250 * 300 = 75000请求Cassandra):48 ms(Q99),31 ms(Q90),11 ms(Q50)
服务的延迟为600 RPS服务(600 * 300 = 180000向Cassandra请求):159 MS(Q99),95 ms(Q90),75 ms(Q50)
Max RPS到Cassandra:650 * 300 = 195000


每个请求使用5个ID测试(总计600个请求通过5个IDS)
550 RPS的延迟服务(550 * 600 = 330000请求Cassandra):97 MS(Q99),92 MS(Q90),60 ms(Q50)
Max RPS到Cassandra:550 * 660 = 363000


每个请求使用1个ID测试(总计3000个请求通过1个IDS)
服务的延迟为190 RPS服务(250 * 3000 = 750000请求Cassandra):49 ms(Q99),43 MS(Q90),30 ms(Q50)
Max RPP到Cassandra:190 * 3000 = 570000
 

I have a Cassandra cluster of 6 nodes, each one has 96 CPU/800 RAM.

My table for performance tests is:

create table if not exists space.table
(
    id          bigint primary key,
    data        frozen<list<float>>,
    updated_at  timestamp
);

Table contains 150.000.000 rows.

When I was testing it with query:

SELECT * FROM space.table WHERE id = X

I even wasn't able to overload cluster, the client was overloaded by itself, RPS to cluster were 350.000.

Now I'm testing a second test case:

SELECT * FROM space.table WHERE id in (X1, X2 ... X3000)

I want to get 3000 random rows from Cassandra per request.

Max RPS in this case 15 RPS after that occurs a lot of pending tasks in Cassandra thread pool with type: Native-Transport-Requests.
Isn't it the best idea to get big resultsets from cassandra? What is the best practice, for sure I can divide 3000 rows to separate requests, for example 30 request each with 100 ids.
Where can I find info about it, maybe WHERE IN operation is not good from performance perspective?

Update:

Want to share my measurements for getting 3000 rows by different chunk size from Cassandra:

Test with 3000 ids per request

Latency: 5 seconds
Max RPS to cassandra: 20


Test with 100 ids per request (total 300 request each by 100 ids)
Latency at 350 rps to service (350 * 30 = 10500 requests to cassandra): 170 ms (q99), 95 ms (q90), 75 ms(q50)
Max RPS to cassandra: 350 * 30 = 10500

Test with 20 ids per request (total 150 request each by 20 ids) 
Latency at 250 rps to service(250 * 150 = 37500 requests to cassandra): 49 ms (q99), 46 ms (q90), 32 ms(q50)
Latency at 600 rps to service(600 * 150 = 90000 requests to cassandra): 190 ms (q99), 180 ms (q90), 148 ms(q50)
Max RPS to cassandra: 650  * 150 = 97500


Test with 10 ids per request (total 300 request each by 10 ids)
Latency at 250 rps to service(250 * 300 = 75000 requests to cassandra): 48 ms (q99), 31 ms (q90), 11 ms(q50)
Latency at 600 rps to service(600 * 300 = 180000 requests to cassandra): 159 ms (q99), 95 ms (q90), 75 ms(q50)
Max RPS to cassandra: 650  * 300 = 195000


Test with 5 ids per request (total 600 request each by 5 ids)
Latency at 550 rps to service(550 * 600 = 330000 requests to cassandra): 97 ms (q99), 92 ms (q90), 60 ms(q50)
Max RPS to cassandra: 550  * 660 = 363000


Test with 1 ids per request (total 3000 request each by 1 ids)
Latency at 190 rps to service(250 * 3000 = 750000 requests to cassandra): 49 ms (q99), 43 ms (q90), 30 ms(q50)
Max RPS to cassandra: 190  * 3000 = 570000

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

别再吹冷风 2025-02-15 19:36:05

中的实际上不建议使用,尤其是对于许多单个分区键。问题在于,当您在中发送

  1. 查询发送到任何节点(协调器节点)时,没有必要的节点,该节点是拥有数据的
  2. ,则该节点note coordinator节点标识哪些节点正在为特定分区拥有数据键
  3. 查询将发送到确定的节点
  4. 协调器节点收集所有节点
  5. 结果的结果,并将其发送回来,

这将大量负载放在协调器节点上,并使整个查询的速度与群集中最慢的节点一样慢。

更好的解决方案是使用准备好的查询并为每个分区键发送单独的异步请求,然后在您的应用程序中收集数据。只要考虑到每个连接可能有多少机架查询是有限制的。

PS应该可以通过查看您的值,查找不同的分区键是否在同一令牌范围内,在查询同一令牌范围内的所有键中生成younk offion ps,可以进一步优化。该查询明确设置路由密钥。但这需要更高级的编码。

The IN is really not recommended to use, especially for so many individual partition keys. The problem is that when you send query with IN:

  1. query sent to the any node (coordinator node), not necessary node that is owning the data
  2. then that coordinator node identifies which nodes are owning data for specific partition keys
  3. queries are sent to identified nodes
  4. coordinator node collects results from all nodes
  5. result is consolidated and sent back

This puts a lot of load onto the coordinator node, and making the whole query as slow as the slowest node in the cluster.

The better solution would be to use prepared queries and sent individual async requests for each of partition keys, and then collect data in your application. Just take into account that there are limits on how many in-flight queries could be per connection.

P.S. It should be possible to optimize that further, by looking into your values, finding if different partition keys are in the same token range, generate the IN query for all keys in the same token range, and send that query setting the routing key explicitly. But it requires more advanced coding.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文