I have just explained the concept of partition in the topic and the partition is actually increased
performance of entire Kafka last, and they optimized the read and write operations because now they
are spread among different Saras.
And also they increase the full tolerance because in case when some rules fail, Özer will continue
processing of messages inside of a specific topic.
And no, let me explain you how messages are stored inside of the partitions recorded in the previous
practice section, we have created a topic called c.D and we didn't specify one of the partitions we
want to create for that topic.
And by default, in such case, only a single partition will be created.
And you have seen that the Kafka broker has created a folder with may see this Bessel zero that the
story's all messages for this particular partition.
That means that every partition is simply a separate folder with files, nothing else.
And if there are multiple partitions spread among different brokers, then every broker may have one
or multiple folders for every partition like it zero it is once, it is two and so on.
If you create a topic with multiple partitions and if there are multiple partitions on different computers,
producers might write messages to different partitions.
For example, in this case there is topic eight with three partitions partition zero one and two.
Notice that the number of the partition is always zero and you're not able to adjust it.
It is behavior does the behavior of a class.
It creates partitions starting from number zero.
For example, if you create the topic with ten partitions, then last the partition number will be nine
and the number of the fourth partition will be zero.
So in this case, there are three partitions, zero, one and two.
And here you see how those partitions are distributed among those brokers.
And notice that the offset numbers instead of every partition are unique and starting from zero.
So, for example, here in this partition, there are only two messages and offset of those messages
are zero and one.
So when Thrillist message arrives to empty partition, it gets offset zero.
Next one will get offset one and so on, two, three, four and so on.
Offset numbers must be unique across partition, not Dobek, because here in this fourth partition,
you see that that also has offset numbers from that to just zero and one same as in this partition.
But those messages are completely different from those messages.
They are simply different messages and same you see here in Partition two.
It's currently four messages with or says from zero to three.
And main idea I want to communicate to you using this diagram is that area partition must have unique
numbers across all messages.
Inside of it is very, very important.
But of the numbers of the messages across entire topic should not be unique in this case.
You see that this message, this one and this one are different messages, but they have same offset
number, but they are located in different partitions.
So producers may write messages to different partitions.
For example, for use of no one may write messages to partition zero.
Producer number two may write messages to partition zero and partition one and producible number three.
Might write messages only to partition to.
Again, every producer decides which party to choose to write.
It is very, very important producer decides that.
And every message that arrives to specific politician, for example, let's say we sent a new message
to partition one, it will be abandoned to the last message that already exists in this partition and
new message in this partition, one will get of that number three.
So now from this diagram, you see that using different partitions, we achieve parallel performance
of writing and regional operations.
So we may write to different partitions in parallel on different brockers same relates to operations.
But now you may ask my question, but what if Broecker one will fail and partition one with all messages
inside of it will simply disappear?
In such case, those messages will be simply lost.
I am talking about message zero one and two instead of partition one and you will not be able to consume
those messages anymore.
They were simply lost because they were stored only in a single place on a single broker.
And there was of course, a solution for this problem.
And you are able to replicate messages inside of every partition.
And if you want to, you are able to replicate every single message inside of the topic multiple times,
for example, five times or ten times.
And in such case, copies of the same message will be stored on different broadcasts.
And in such case, if one of those brokers fails, also, it will be able to sell the same messages
to consumers, this idea behind replication.
And now let's discuss the application in greater details and talk about leader and let's do the text
by.