对于每 3 小时 20GB 数据文件等模式,批量加载到 Bigtable 的最佳方法是什么?数据流是正确的方式吗?
我们使用 Dataflow 批量加载 Bigtable 的问题是..
看起来 Dataflow QPS 与 Bigtable(5 个节点)的 QPS 不匹配。我正在尝试使用 Dataflow 将 20GB 文件加载到 bigtable。摄取到 bigtable 需要 4 小时。我也在运行过程中不断收到此警告..
{
"code" : 429,
"errors" : [ {
"domain" : "global",
"message" : "Request throttled due to project QPS limit being reached.",
"reason" : "rateLimitExceeded"
} ],
"message" : "Request throttled due to project QPS limit being reached.",
"status" : "RESOURCE_EXHAUSTED"
}.
代码:
// CloudBigtableOptions is one way to retrieve the options. It's not
// required.
CloudBigtableOptions options = PipelineOptionsFactory.fromArgs(btargs.toArray(new String[btargs.size()]))
.withValidation().as(CloudBigtableOptions.class);
// CloudBigtableTableConfiguration contains the project, zone, cluster
// and table to connect to.
CloudBigtableTableConfiguration config = CloudBigtableTableConfiguration.fromCBTOptions(options);
Pipeline p = Pipeline.create(options);
// This sets up serialization for Puts and Deletes so that Dataflow can
// potentially move them through the network.
CloudBigtableIO.initializeForWrite(p);
p.apply(TextIO.Read.from(inpath)).apply(ParDo.of(new CreatePutsFn(columns, delim)))
.apply(CloudBigtableIO.writeToTable(config));
p.run();
CreatePutsFn:
@Override
public void processElement(DoFn<String, Mutation>.ProcessContext c) throws Exception {
String[] vals = c.element().split(this.delim);
for (int i = 0; i < columns.length; i++) {
if (i != keyPos && vals[i].trim() != "") {
c.output(new Put(vals[keyPos].getBytes()).addColumn(FAMILY, Bytes.toBytes(columns[i].toLowerCase()),
Bytes.toBytes(vals[i])));
}
}
}
非常感谢这里的任何帮助。谢谢