我正在尝试使用Streamparse在Python中编写一个简单的Storm拓扑。除了我写的简单的卡夫卡鲸鱼嘴外,一切都在为我工作 - 似乎只是不断地称之为“next_tuple”。我的螺栓相当慢,所以系统似乎很快在内存中爆炸。
启动拓扑,我尝试将topology.max.spout.pending设置为1,以防止它向拓扑添加太多消息。
lein run -m streamparse.commands.run/-main topologies/.clj -t 100 --option 'topology.max.spout.pending=1' --option 'topology.workers=1' --option 'topology.acker.executors=1'
然而,结果仍然是这样,尽管螺栓要慢得多:
24790 [Thread-16-metadata-spout] INFO backtype.storm.spout.ShellSpout - Shell msg: ----NEXT TUPLE----
24942 [Thread-16-metadata-spout] INFO backtype.storm.spout.ShellSpout - Shell msg: ----NEXT TUPLE----
24944 [Thread-16-metadata-spout] INFO backtype.storm.spout.ShellSpout - Shell msg: ----NEXT TUPLE----
24946 [Thread-16-metadata-spout] INFO backtype.storm.spout.ShellSpout - Shell msg: ----NEXT TUPLE----
25143 [Thread-16-metadata-spout] INFO backtype.storm.spout.ShellSpout - Shell msg: ----NEXT TUPLE----
25144 [Thread-16-metadata-spout] INFO backtype.storm.spout.ShellSpout - Shell msg: ----NEXT TUPLE----
25350 [Thread-16-metadata-spout] INFO backtype.storm.spout.ShellSpout - Shell msg: ----NEXT TUPLE----
......
我简单的卡夫卡鲸鱼嘴:
class MetadataSpout(Spout):
def initialize(self, stormconf, context):
self.log('----CONFIG: %s----' % stormconf)
k = KafkaClient(os.getenv('KAFKA'))
self.consumer = SimpleConsumer(k, 'vacuum', 'metadata')
def next_tuple(self):
self.log('----NEXT TUPLE----')
messages = self.consumer.get_messages(count=os.getenv('BATCH_COUNT', 20))
self.emit([json.dumps([m.message.value for m in messages])])
我的螺栓只有默认配置,但需要花费大量时间才能完成process()方法。我无法弄清楚它们是如何成为问题的,但我可以发布它们是否相关。
答案 0 :(得分:2)
Solved, thanks to the great Streamparse team
“topology.max.spout.pending只有在您的spout可靠时才有效。您需要指定要发出的可选tup_id参数,以便为每个元组提供唯一的ID。一旦这样做,一切都应该很好。“
为发出的元组指定UUID后,此问题已解决。