Cassandra:快速加载大数据

QR_*_*ica 5 copy cassandra

我们目前正在单个节点集群上与Cassandra合作,以测试其上的应用程序开发.现在,我们有一个非常庞大的数据集,包含大约70万行文本,我们希望将其转储到Cassandra中.

我们尝试了以下所有方法:

  • 使用python Cassandra驱动程序逐行插入
  • 复制Cassandra命令
  • 将sstable的压缩设置为none

我们已经探索了sstable批量加载器的选项,但我们没有适当的.db格式.我们要加载的文本文件有70M行,看起来像:

2f8e4787-eb9c-49e0-9a2d-23fa40c177a4    the magnet programs succeeded in attracting applicants and by the mid-1990s only #about a #third of students who #applied were accepted.
Run Code Online (Sandbox Code Playgroud)

我们打算插入的列系列具有以下创建语法:

CREATE TABLE post (
  postid uuid,
  posttext text,
  PRIMARY KEY (postid)
) WITH
  bloom_filter_fp_chance=0.010000 AND
  caching='KEYS_ONLY' AND
  comment='' AND
  dclocal_read_repair_chance=0.000000 AND
  gc_grace_seconds=864000 AND
  index_interval=128 AND
  read_repair_chance=0.100000 AND
  replicate_on_write='true' AND
  populate_io_cache_on_flush='false' AND
  default_time_to_live=0 AND
  speculative_retry='99.0PERCENTILE' AND
  memtable_flush_period_in_ms=0 AND
  compaction={'class': 'SizeTieredCompactionStrategy'} AND
  compression={};
Run Code Online (Sandbox Code Playgroud)

问题:将数据加载到一个简单的列族中需要永远 - 对于插入的30M行,需要5小时.我们想知道是否有任何方法可以加快这一点,因为在我们的服务器上加载到MySQL的相同数据的70M行的性能大约需要6分钟.

我们想知道我们是否错过了什么?或者,如果有人能指出我们正确的方向?

提前谢谢了!

psa*_*ord 4

sstableloader 是将数据导入 Cassandra 的最快方法。您必须编写代码来生成 sstables,但如果您真的关心速度,这将为您带来最大的收益。

本文有点旧,但基础知识仍然适用于如何生成 SSTables

如果您确实不想使用 sstableloader,那么您应该能够通过并行执行插入来加快速度。单个节点可以同时处理多个连接,并且您可以扩展 Cassandra 集群以提高吞吐量。