Apache spark 卡桑德拉火花连接器读取性能
我有一些火花的经验,但刚开始与卡桑德拉。我正试图做一个非常简单的阅读,但却得到了非常糟糕的表现——不知道为什么。以下是我正在使用的代码:Apache spark 卡桑德拉火花连接器读取性能,apache-spark,spark-cassandra-connector,Apache Spark,Spark Cassandra Connector,我有一些火花的经验,但刚开始与卡桑德拉。我正试图做一个非常简单的阅读,但却得到了非常糟糕的表现——不知道为什么。以下是我正在使用的代码: sc.cassandraTable("nt_live_october","nt") .where("group_id='254358'") .where("epoch >=1443916800 and epoch<=1444348800") .first
sc.cassandraTable("nt_live_october","nt")
.where("group_id='254358'")
.where("epoch >=1443916800 and epoch<=1444348800")
.first
sc.cassandraTable(“新界10月直播”,“新界”)
.其中(“组id='254358')
其中(“epoch>=1443916800和epoch我认为问题在于分区之间的数据分布。您的表有一个集群(分区)键-groupId,epoch只是一个集群列。数据只按groupId分布在集群节点上,因此在集群的一个节点上有一个groupId='254358'的巨大分区。
运行查询时,Cassandra以groupId='254358'到达非常快的分区,然后过滤所有行以查找纪元介于1443916800和1444348800之间的记录。如果有很多行,则查询速度会非常慢。实际上,此查询不是分布式的,它将始终在一个节点上运行
更好的做法是提取日期甚至小时,并将其添加为分区键,在您的示例中类似于
PRIMARY KEY ((group_id, date), epoch, group_name, auto_generated_uuid_field)
WITH CLUSTERING ORDER BY (epoch ASC, group_name ASC, auto_generated_uuid_field ASC)
为了验证我的假设,您可以在cqlsh中运行当前查询,并打开跟踪读取如何执行。因此,问题与Spark无关
关于错误和获取它的时间,一切都很好,因为您在超时发生后收到错误
我还记得spark cassandra connector的建议,即将spark从节点精确地连接到cassandra节点,以便通过分区键分发查询