Cassandra写超时写

Cassandra writing timeout writing

我正在尝试将数据插入 Cassandra。我有一个 1M4 整数列表,我想将其插入具有以下架构的 table 中:

CREATE TABLE IF NOT EXISTS my_table (
     node_id bigint,
     screen_name text,
     centrality float,
     friend_follower_id bigint,
     is_friend boolean,
     is_follower boolean,
     PRIMARY KEY ((node_id), friend_follower_id));

为了插入数据,我执行了以下操作:

prepared_statement = session.prepare("INSERT INTO {0} (node_id, screen_name, friend_follower_id, centrality, is_follower) VALUES ({1}, {2}, ?, {3}, true)".format("met_table", author_id, author_username, 0.0)
execute_concurrent_with_args(session, prepared_statement, zip(followers))

错误如:

cassandra.WriteTimeout: Error from server: code1100 [Coordinator node timed out waiting for replica nodes' responses] message="Operation timed -out received only 0 responses." info={'consistency': LOCAL_ONE, 'received_response':0, 'required_response':1}

写入大数据时如何避免超时?

该错误表示服务器端协调器超时。这由 cassandra.yaml 设置 write_request_timeout_in_ms 控制。你可以尝试提高它。

当集群不堪重负并且服务器 GC 暂停挂起副本时,有时会观察到这种情况。但是,它在更高的一致性级别上更常见。您还没有说明集群大小或复制因子。你是 运行 RF=3 吗?

最后,如果您的集群分配无法处理此写入工作负载,可以通过将 concurrency 参数减少到 execute_concurrent_with_args 来减轻负载。