Book Image

Learning Apache Kafka - Second Edition

By : Nishant Garg
Book Image

Learning Apache Kafka - Second Edition

By: Nishant Garg

Overview of this book

<p>Kafka is one of those systems that is very simple to describe at a high level but has an incredible depth of technical detail when you dig deeper.</p> <p>Learning Apache Kafka Second Edition provides you with step-by-step, practical examples that help you take advantage of the real power of Kafka and handle hundreds of megabytes of messages per second from multiple clients. This book teaches you everything you need to know, right from setting up Kafka clusters to understanding basic blocks like producer, broker, and consumer blocks. Once you are all set up, you will then explore additional settings and configuration changes to achieve ever more complex goals. You will also learn how Kafka is designed internally and what configurations make it more effective. Finally, you will learn how Kafka works with other tools such as Hadoop, Storm, and so on.</p>
Table of Contents (14 chapters)

Replication in Kafka


Before we talk about replication in Kafka, let's talk about message partitioning. In Kafka, a message partitioning strategy is used at the Kafka broker end. The decision about how the message is partitioned is taken by the producer, and the broker stores the messages in the same order as they arrive. The number of partitions can be configured for each topic within the Kafka broker.

Kafka replication is one of the very important features introduced in Kafka 0.8. Though Kafka is highly scalable, for better durability of messages and high availability of Kafka clusters, replication guarantees that the message will be published and consumed even in the case of broker failure, which may be caused by any reason. Both producers and consumers are replication-aware in Kafka. The following diagram explains replication in Kafka:

Let's discuss the preceding diagram in detail.

In replication, each partition of a message has n replicas and can afford n-1 failures to guarantee message...