vatsal mevada
vatsal mevada

Reputation: 5616

Increase no of records read in single poll of KafkaConsumer

My Kafka version is: 0.10.0.1

When I am polling the records using org.apache.kafka.clients.consumer.KafkaConsumer#poll method, it is fetching very less no records than my max.poll.records value.

I am looking for some configuration setting using which I can increase the no of records polled in a single poll.

I have tried increasing max.poll.interval.ms property of kafka consumer but it doesn't help.

Consumer configuration:

    metric.reporters = []
    metadata.max.age.ms = 300000
    partition.assignment.strategy = [org.apache.kafka.clients.consumer.RangeAssignor]
    reconnect.backoff.ms = 50
    sasl.kerberos.ticket.renew.window.factor = 0.8
    max.partition.fetch.bytes = 1048576
    bootstrap.servers = [broker1:9092, broker2:9092]
    ssl.keystore.type = JKS
    enable.auto.commit = true
    sasl.mechanism = GSSAPI
    interceptor.classes = null
    exclude.internal.topics = true
    ssl.truststore.password = null
    client.id = 
    ssl.endpoint.identification.algorithm = null
    max.poll.records = 5000
    check.crcs = true
    request.timeout.ms = 600500
    heartbeat.interval.ms = 3000
    auto.commit.interval.ms = 5000
    receive.buffer.bytes = 65536
    ssl.truststore.type = JKS
    ssl.truststore.location = null
    ssl.keystore.password = null
    fetch.min.bytes = 30000000
    send.buffer.bytes = 131072
    value.deserializer = class org.apache.kafka.common.serialization.StringDeserializer
    group.id = G1
    retry.backoff.ms = 100
    sasl.kerberos.kinit.cmd = /usr/bin/kinit
    sasl.kerberos.service.name = null
    sasl.kerberos.ticket.renew.jitter = 0.05
    ssl.trustmanager.algorithm = PKIX
    ssl.key.password = null
    fetch.max.wait.ms = 500
    sasl.kerberos.min.time.before.relogin = 60000
    connections.max.idle.ms = 540000
    session.timeout.ms = 60000
    metrics.num.samples = 2
    key.deserializer = class org.apache.kafka.common.serialization.StringDeserializer
    ssl.protocol = TLS
    ssl.provider = null
    ssl.enabled.protocols = [TLSv1.2, TLSv1.1, TLSv1]
    ssl.keystore.location = null
    ssl.cipher.suites = null
    security.protocol = PLAINTEXT
    ssl.keymanager.algorithm = SunX509
    metrics.sample.window.ms = 30000
    auto.offset.reset = earliest

Upvotes: 5

Views: 4311

Answers (2)

Leon
Leon

Reputation: 3244

Change max.partition.fetch.bytes will do the trick.

E.g., with below settings 123456 records are returned by each poll:

props.put("max.poll.records", "123456");
props.put("max.partition.fetch.bytes","100000000");

Upvotes: 0

groo
groo

Reputation: 4448

I believe you'll need to increase fetch.max.wait.ms that is in your current configuration the default 500.

From docs:

fetch.max.wait.ms: The maximum amount of time the server will block before answering the fetch request if there isn't sufficient data to immediately satisfy the requirement given by fetch.min.bytes.

Upvotes: 2

Related Questions