Cassandra写超时写
Posted
技术标签:
【中文标题】Cassandra写超时写【英文标题】:Cassandra writing timeout writing 【发布时间】:2017-07-29 23:41:54 【问题描述】:我正在尝试将数据插入 Cassandra。我有一个 1M4 整数列表,我想将其插入具有以下架构的表中:
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
在写入大量数据时如何避免超时?
【问题讨论】:
【参考方案1】:该错误表明服务器端协调器超时。这由cassandra.yaml
设置write_request_timeout_in_ms
管理。您可以尝试提高它。
当集群不堪重负并且服务器 GC 暂停挂起副本时,有时会观察到这种情况。但是,在更高的一致性级别上更常见。您还没有提及您的集群大小或复制因子。您是否使用 RF=3 运行?
最后,如果您的集群分配无法处理这种写入工作负载,可以通过将concurrency
参数减少到execute_concurrent_with_args
来减轻负载。
【讨论】:
我正在使用本地主机。我的复制因子设置为 2。 我增加了(x10)write_request_timeout,但我遇到的问题是我的电脑速度很慢,我认为我的代码卡住了。一半数据已插入,但其他数据尚未插入。我计算了我要插入的列表的大小,大小约为 10MB,这是一个正常的用例吗?我应该把它分成更小的块吗?以上是关于Cassandra写超时写的主要内容,如果未能解决你的问题,请参考以下文章