How many operating system resources is needed for one Java Kafka Consumer?

Max :

I want to use hundreds of thousands of KafkaConsumer. For example, I need 100_000 consumers for some architectural pattern. I am thinking, is it OK? Or should I to refactor my system and use few consumers for the whole system (for example, 10 consumers instead of 100_000).

So, my questions are:

  1. Is there connection pool in KafkaConsumer, or each consumer creates own connection to kafka brokers?
  2. Is there thread pool in KafkaConsumer, or each consumer creates own thread (I hope, it does not).
  3. What is average memory consumption per KafkaConsumer?
  4. What do you think about such architectural pattern?
Giorgos Myrianthous :

1,2) Consumers request metadata from one of the brokers which is the leader of the partition. Each consumer is able to handle all IO from a single thread as the Java clients are designed around an event loop which is driven by the poll(). You can also build multi-threaded consumers but you'd need take care of offset management. Refer to Confluent's documentation for more details regarding the implementation of Java Clients.

3) According to Apache Kafka and Confluent Enterprise Reference architecture,

Consumers use at least 2MB per consumer and up to 64MB in cases of large responses from brokers (typical for bursty traffic)

4) The number of consumers you've mentioned is huge so you'd need a very good reason to go for 100,000 consumers. It depends on the scenario though, but even Netflix should be using a lot less than that.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=159741&siteId=1