InterviewSolution
| 1. |
What do you mean by an unbalanced cluster in Kafka? How can you balance it? |
||||||||||||||||||||||||||||||||||||||||
|
Answer» It's as simple as assigning a UNIQUE broker id, listeners, and log directory to the server.properties file to add new brokers to an existing Kafka cluster. However, these brokers will not be allocated any data PARTITIONS from the cluster's existing topics, so they won't be performing much work unless the partitions are moved or new topics are formed. A cluster is referred to as unbalanced if it has any of the following problems : Leader Skew: Consider the following scenario: a topic with three partitions and a replication factor of three across three brokers. The leader receives all READS and writes on a partition. Followers send fetch requests to the leaders in order to receive their most recent messages. Followers exist solely for redundancy and fail-over purposes. Consider the case of a broker who has failed. It's possible that the failed broker was a collection of numerous leader partitions. Each unsuccessful broker's leader partition is promoted as the leader by its followers on the other brokers. Because fail-over to an out-of-sync replica is not allowed, the follower must be in sync with the leader in order to be promoted as the leader. If another broker goes down, all of the leaders are on the same broker, therefore there is no redundancy. When both brokers 1 and 3 go live, the partitions gain some redundancy, but the leaders stay focused on broker 2. As a result, the Kafka brokers have a leader imbalance. When a node is a leader for more partitions than the number of partitions/number of brokers, the cluster is in a leader skewed condition. Solving the leader skew problem: Kafka offers the ability to reassign leaders to the desired replicas in order to tackle this problem. This can be accomplished in one of two ways:
Broker Skew: Let us consider a Kafka cluster with nine brokers. Let the topic name be "sample_topic." The following is how the brokers are assigned to the topic in our example:
On brokers 3,4 and 5, the topic “sample_topic” is skewed. This is because if the number of partitions per broker on a given issue is more than the average, the broker is considered to be skewed. Solving the broker skew problem : The following steps can be used to solve it:
|
|||||||||||||||||||||||||||||||||||||||||