gpt4 book ai didi

apache-storm - Storm-kafka spout 消耗缓慢

转载 作者:行者123 更新时间:2023-12-04 04:48:39 25 4
gpt4 key购买 nike

我只是在尝试这里提到的 kafka-storm spout https://github.com/nathanmarz/storm-contrib/tree/master/storm-kafka我使用的配置如下所示。

    BrokerHosts brokerHosts = KafkaConfig.StaticHosts.fromHostString(
ImmutableList.of("localhost"), 1);
SpoutConfig spoutConfig = new SpoutConfig(brokerHosts, // list of Kafka
"test", // topic to read from
"/kafkastorm", // the root path in Zookeeper for the spout to
"discovery"); // an id for this consumer for storing the
// consumer offsets in Zookeeper
spoutConfig.scheme = new StringScheme();
spoutConfig.stateUpdateIntervalMs = 1000;


KafkaSpout kafkaSpout = new KafkaSpout(spoutConfig);

TridentTopology topology = new TridentTopology();
InetSocketAddress inetSocketAddress = new InetSocketAddress(
"localhost", 6379);
TridentState wordsCount = topology
.newStream(SPOUT_FIRST, kafkaSpout)
.parallelismHint(1)
.each(new Fields("str"), new TestSplit(), new Fields("words"))
.groupBy(new Fields("words"))
.persistentAggregate(
RedisState.transactional(inetSocketAddress),
new Count(), new Fields("counts")).parallelismHint(100);

Config conf = new Config();
conf.setMaxTaskParallelism(200);
// conf.setDebug( true );
// conf.setMaxSpoutPending(20);

// This topology can only be run as local because it is a toy example
LocalDRPC drpc = new LocalDRPC();
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("symbolCounter", conf, topology.build());

但是上面的 spout 从 Kafka 主题中获取消息的速度大约是 7000/秒,但我预计每秒加载大约 50000 条消息。我尝试了各种增加 spoutConfig 中的提取缓冲区大小的选项,但没有看到任何结果。

有没有人遇到过无法以生产者生产消息的速度通过storm获取kafka主题的类似问题?

最佳答案

我将配置中的“topology.spout.max.batch.size”值更新为大约 64*1024 值,然后 Storm 处理变得很快。

关于apache-storm - Storm-kafka spout 消耗缓慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19705979/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com