我测试了我的python-kafka脚本,kafka-producer产生了10000 / s的消息,但我耗费了大约1000 / s,那么如何在整个过程中改善我的消费者呢?
while True:
topic_to_records = consumer.poll(100)
if len(topic_to_records.values()) == 0:
time.sleep(0.05)
for records in topic_to_records.values():
print 'consume %s messages' % len(records)
for msg in records:
print (time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()), '*'+msg.value.split('\t')[0])