Nikem
Nikem

Reputation: 5784

What happens when one of the Kafka replicas is down

I have a cluster of 2 Kafka brokers and a topic with replication factor 2. If one of the brokers dies, will my producers be able to continue sending new messages to this degraded cluster of 1 node? Or replication factor 2 requires 2 alive nodes and messaged will be refused?

Upvotes: 3

Views: 7322

Answers (5)

Hector R.
Hector R.

Reputation: 11

Kafka will handle reassigning partitions for producers and consumers that where dealing with the partitions lost, but it will problematic for new topics.

You could start one broker with a replication factor of 2 or 3. It does work. However, you could not create a topic with that replication factor until you have that amount of brokers in the cluster. Either the topic is auto generated on the first message or created manually, kafka will throw an error.

  • kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 3 --partitions 1 --topic test

Error while executing topic command : Replication factor: 3 larger than available brokers: 1. [2018-08-08 15:23:18,339] ERROR org.apache.kafka.common.errors.InvalidReplicationFactorException: Replication factor: 3 larger than available brokers: 1.

Upvotes: 1

Mohamed Elkady
Mohamed Elkady

Reputation: 21

replication-factor 2 doesn't require 2 live brokers, it publish message while one broker is down depends on those configurations - acks - min.insync.replicas

Check those configurations as mentioned above @Javier

Upvotes: 0

Javier Holguera
Javier Holguera

Reputation: 1351

It depends on a few factors:

  • What is your producer configuration for acks? If you configure to "all", the leader broker won't answer with an ACK until the message have been replicated to all nodes in ISR list. At this point is up to your producer to decide if he cares about ACKs or not.
  • What is your value for min.insync.replicas? If the number of nodes is below this config, your broker leader won't accept more messages from producers until more nodes are available.

So basically your producers may get into a pause for a while, until more nodes are up.

Upvotes: 12

Yassine Abdul-Rahman
Yassine Abdul-Rahman

Reputation: 13

As soon as new node joined to the kafka cluster, data will be replicated, the replicas factor does not effect the publisher messages

Upvotes: 0

Kamal Chandraprakash
Kamal Chandraprakash

Reputation: 2002

Messages will not be ignored if the no. of alive brokers is lesser than the configured replicas. Whenever a new Kafka broker joins the cluster, the data gets replicated to that node.

You can reproduce this scenario by configuring the replication factor as 3 or more and start only one broker.

Upvotes: 5

Related Questions