I have following questions regarding Kafka:
If I create a topic and specify no of partitions more than no of brokers, then a single broker will handle more than 1 partition?
If I create a topic and specify replication factor more than no of brokers, will the topic create or not?
Can a single broker will handle multiple partitions of different topic.
Yes, a broker can handle numerous partitions on multiple topics. There is an overhead to having more partitions, so choosing the "right" number requires knowledge of many factors.
You can have fewer consumers than partitions (in which case consumers get messages from multiple partitions), but if you have more consumers than partitions some of the consumers will be “starved” and not receive any messages until the number of consumers drops to (or below) the number of partitions.
For most implementations you want to follow the rule of thumb of 10 partitions per topic, and 10,000 partitions per Kafka cluster. Going beyond that amount can require additional monitoring and optimization.
+-------------------+
| Topic X |
| Partition 0 |
| |
| |
| Topic X |
| Partition 1 |
+-------------------+
--replication-factor 3
and only one available broker: >> bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 3 --partitions 1 --topic myTestTopic
Error while executing topic command replication factor: 3 larger than available
brokers: 1
kafka.admin.AdminOperationException: replication factor: 3 larger than available
brokers: 1
at kafka.admin.AdminUtils$.assignReplicasToBrokers(AdminUtils.scala:70)
at kafka.admin.AdminUtils$.createTopic(AdminUtils.scala:171)
at kafka.admin.TopicCommand$.createTopic(TopicCommand.scala:93)
at kafka.admin.TopicCommand$.main(TopicCommand.scala:55)
at kafka.admin.TopicCommand.main(TopicCommand.scala)
replication-factor=1
. An example overview of your brokers is shown below: +-------------------+
| Topic 1 |
| Partition 0 |
| |
| |
| Topic 3 |
| Partition 1 |
| |
| |
| Topic 2 |
| Partition 1 |
+-------------------+
+-------------------+
| Topic 1 |
| Partition 1 |
| |
| |
| Topic 3 |
| Partition 0 |
| |
| |
| Topic 2 |
| Partition 0 |
+-------------------+
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With