Skip to content

Question: Parallel polling and multiple consumers with confluent-kafka-go v2 #1454

@nurlybekovnt

Description

@nurlybekovnt

Hi there, @emasab @rayokota! 👋

In the official examples for confluent-kafka-go v2 a single Consumer is created with kafka.NewConsumer, and consumer.Poll() is called in the main goroutine. My kafka topic has four partitions, so I'm trying to understand the recommended approach for higher throughput and less RAM concumption:

  1. Parallel polling:
    • Is it OK (or even expected) to call consumer.Poll() from four separate goroutines, one per partition?
  2. Multiple consumers:
    • Alternatively, should I create four separate Consumer instances (in the same consumer group)?
    • If I do this, will each instance be assigned a dedicated partition, or will messages still be interleaved across them?
  3. Best practice:
    • What is the canonical way to scale reads when a single consumer can't keep up and Kafka lag starts to grow?

Any guidance or links to relevant docs or examples would be much appreciated. Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions