This is the 9th day of my participation in the August Wen Challenge.More challenges in August

The body of the

  1. Instead of using producer.send(MSG), use producer.send(MSG, callback).
  2. Set acks = all. Acks are a parameter of Producer that represents your definition of a “committed” message. If set to all, it means that all replica brokers must receive the message before it is considered “committed.” This is the highest level of “submitted” definition.
  3. Sets retries to a larger value. The retries parameter is also a parameter of Producer, which automatically retries the Producer. When transient jitter occurs, messages may fail to be sent. In this case, a Producer whose REtries > 0 is configured can automatically retry message sending to avoid message loss.
  4. Set the unclean. Leader. Election. The enable = false. This is the Broker side parameter that controls which brokers are eligible to run as the Leader of a partition. If a Broker falls too far behind the original Leader, messages will inevitably be lost once it becomes the new Leader. Therefore, this parameter must be set to false, that is, it is not allowed to happen.
  5. Replication. factor >= 3. This is also the parameter on the Broker side. The idea here is that it’s best to keep multiple copies of messages, since redundancy is currently the main mechanism for preventing message loss.
  6. Set min.insync.replicas > 1. This is still the broker-side parameter and controls the minimum number of copies to which a message must be written before it is considered “committed”. Setting it to greater than 1 improves message persistence. Never use the default value of 1 in the real world.
  7. Make sure replica.factor > min.insync.replicas. If the two are equal, then only one copy hangs up and the entire partition fails. Not only do we need to improve message persistence and prevent data loss, but we need to do it without compromising availability. Replication. factor = min.insync.replicas + 1 is recommended.
  8. Ensure message consumption completes before submission. The Consumer side has a parameter enable.auto.mit. It is best to set it to false and manually commit the shift.