0

I test my python-kafka script, the kafka-producer produced 10000/s message, but I consumed about 1000/s, so how to improve my consumer throughout?

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])
lizx
  • 21
  • 1
  • 5

0 Answers0