Skip to content

Producer compression might not be functional? #480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
4 tasks
mtrienis opened this issue Nov 5, 2018 · 3 comments
Closed
4 tasks

Producer compression might not be functional? #480

mtrienis opened this issue Nov 5, 2018 · 3 comments

Comments

@mtrienis
Copy link

mtrienis commented Nov 5, 2018

Description

It looks like Producer compression might not be working, or it's not providing the right meta data.

How to reproduce

from confluent_kafka import KafkaException, Producer
producer = Producer({"bootstrap.servers":"localhost:9092", 'api.version.request': True, 'compression.type':'lz4'})
producer.produce('blah', 'helloworld')
bin/kafka-run-class kafka.tools.DumpLogSegments --files blah-0/00000000000000000000.log --print-data-log
Dumping /tmp/confluent.RviL8Mcp/kafka/data/blah-0/00000000000000000000.log
Starting offset: 0
offset: 0 position: 0 CreateTime: 1541440525795 isvalid: true keysize: -1 valuesize: 10 magic: 2 compresscodec: NONE producerId: -1 producerEpoch: 0 sequence: -1 isTransactional: false headerKeys: [] payload: helloworld

Checklist

Please provide the following information:

  • confluent-kafka-python and librdkafka version (confluent_kafka.version() and confluent_kafka.libversion()):

confluent-kafka-0.11.4

print confluent_kafka.version()
('0.11.4', 721920)

print confluent_kafka.libversion()
('0.11.4', 722175)

  • Apache Kafka broker version:

confluent 5.0.0

  • Client configuration: {...}

producer = Producer({"bootstrap.servers":"localhost:9092", 'api.version.request': True, 'compression.type':'lz4'})

@edenhill
Copy link
Contributor

edenhill commented Nov 5, 2018

It will only compress data if it actually becomes smaller than the uncompressed data.

@mtrienis
Copy link
Author

mtrienis commented Nov 5, 2018

Thanks for the quick response @edenhill, you're are correct!

@yangyu66
Copy link

@mtrienis also you should use "compression.codec" rather than ".type" for python lib.

With the C/C++, Python and Go clients, you can use batch.num.messages to set a limit on the number of messages contained in each batch. To enable compression, use compression.codec.

from https://docs.huihoo.com/apache/kafka/confluent/3.1/clients/producer.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants