Skip to contentমূল লেখায় যান

Case 01 · System designকেস 01 · System design

How Apache Kafka Works

Apache Kafka moves data between the programs of a company. One program writes an event, such as "a user paid for an order", and many other programs read it, now or days later. Source 1সোর্স 1 It is hard to build because Kafka must take in huge amounts of data, keep it in order, never lose it, and keep working when machines fail.

9 min read9 মিনিটে পড়া যায় · 10 sections10টি সেকশন · 1 source1টি সোর্স · updated Nov 2026আপডেট: Nov 2026

Partitions split the readingপার্টিশন পড়ার কাজ ভাগ করে

A topic with partitions is shared by a consumer group. Add consumers, see the limit, then lose a broker.পার্টিশনসহ একটা topic একটা কনজিউমার গ্রুপ ভাগ করে নেয়। কনজিউমার যোগ করুন, সীমা দেখুন, তারপর একটা broker হারান।

3 min3 মিনিট8 steps8টি ধাপ
  • Next offsetপরের offset5
  • Partitionsপার্টিশন3
Producerপ্রোডিউসারappend at endশেষে যোগ012345P0 log · next 5P0 log · পরের 5Broker 1ব্রোকার 1lead: P0লিডার: P0Broker 2ব্রোকার 2lead: P1লিডার: P1Broker 3ব্রোকার 3lead: P2লিডার: P2consumer groupকনজিউমার গ্রুপ

You’ll learnআপনি শিখবেন

  • Each partition is its own logপ্রতিটা partition নিজের আলাদা log
  • Who leads and who copiesকে leader আর কে কপি করে
  • One consumer per partition in a groupগ্রুপে একটা partition-এ একটা কনজিউমার
  • Why extra consumers sit idleবাড়তি কনজিউমার কেন অলস
  • How a new leader takes overনতুন leader কীভাবে দায়িত্ব নেয়

The problem in plain words

A large company runs hundreds of services. Each service makes data that other services need. LinkedIn had this problem, and it built Kafka in 2010 to solve it. Source 1সোর্স 1 In 2011, Kafka became open source and went to the Apache Software Foundation. Source 1সোর্স 1

Without a central system, each pair of services needs its own data pipe, called a pipeline. When the number of services is N, the number of pipes grows like N times N. Source 1সোর্স 1 Kafka puts one central store in the middle. A writer sends its data to Kafka one time. Each reader takes the data from Kafka when it needs it. Source 1সোর্স 1

The article quotes an estimate by Confluent: more than 70 % of Fortune 500 companies use Kafka. Source 1সোর্স 1 Kafka was built for the case where many systems read the same message, so a cluster often reads several times more data than it writes. Source 1সোর্স 1

The article is by a guest author, Stanislav Kozlovski, an Apache Kafka committer. Source 1সোর্স 1 It describes the real open-source Kafka, not an interview-style design.

সহজ English

A large company runs hundreds of services. Each service makes data that other services need. LinkedIn had this problem, and it built Kafka in 2010 to solve it. Source 1সোর্স 1 In 2011, Kafka became open source and went to the Apache Software Foundation. Source 1সোর্স 1

Without a central system, each pair of services needs its own data pipe. When there are N services, the number of pipes grows like N times N. Source 1সোর্স 1 Kafka puts one central store in the middle. A writer sends its data to Kafka one time. Each reader takes the data from Kafka when it needs it. Source 1সোর্স 1

The article quotes an estimate by Confluent: more than 70 % of Fortune 500 companies use Kafka. Source 1সোর্স 1 Kafka was built for the case where many systems read the same message. So a cluster often reads several times more data than it writes. Source 1সোর্স 1

The article is by a guest author who is an Apache Kafka committer. Source 1সোর্স 1 It describes the real open-source Kafka, not an interview-style design.

বাংলা ব্যাখ্যা

একটি বড় company শত শত service চালায়। প্রতিটি service এমন data তৈরি করে, যা অন্য service-এর দরকার হয়। LinkedIn-এর এই সমস্যা ছিল, এবং এর সমাধানে LinkedIn 2010 সালে Kafka তৈরি করে। Source 1সোর্স 1 2011 সালে Kafka open source হয় এবং Apache Software Foundation-এ যায়। Source 1সোর্স 1

কোনো central system না থাকলে প্রতিটি জোড়া service-এর জন্য আলাদা data pipe লাগে, যাকে pipeline বলে। Service-এর সংখ্যা N হলে pipe-এর সংখ্যা প্রায় N গুণ N হারে বাড়ে। Source 1সোর্স 1 Kafka মাঝখানে একটি central store রাখে। একজন writer তার data একবার Kafka-তে পাঠায়। প্রতিটি reader যখন দরকার, তখন Kafka থেকে data নেয়। Source 1সোর্স 1

Article-টি Confluent-এর একটি estimate উল্লেখ করে: Fortune 500-এর 70 %-এর বেশি company Kafka ব্যবহার করে। Source 1সোর্স 1 Kafka এমন অবস্থার জন্য তৈরি, যেখানে অনেক system একই message পড়ে। তাই একটি cluster প্রায়ই যত data লেখে, তার কয়েক গুণ বেশি data পড়ে। Source 1সোর্স 1

Article-টি লিখেছেন একজন guest author, যিনি একজন Apache Kafka committer। Source 1সোর্স 1 এটি আসল open-source Kafka-র বর্ণনা দেয়, কোনো interview-style design-এর নয়।

The big picture

[Producer: checkout app] --write--> [Kafka cluster: 3 or more brokers]
                                      topic "payments"
                                        partition 0: leader on broker 1, copies on 2 and 3
                                        partition 1: leader on broker 2, copies on 1 and 3
                                        partition 2: leader on broker 3, copies on 1 and 2
                                          ^
                                          |  choose leaders, watch broker health
                                     [Controllers (KRaft)]

[Kafka cluster] --read--> [Consumer group "fraud-check"]  consumer A, consumer B
[Kafka cluster] --read--> [Consumer group "accounting"]   consumer C

A producer writes an event to a topic, and Kafka puts it in one partition. Each partition has copies on three brokers. The controllers watch the brokers and choose a leader for each partition. Each consumer group reads the whole topic, and the members of one group split the partitions between them.

সহজ English

The diagram shows a Kafka cluster with 3 or more brokers. A producer writes an event to a topic, and Kafka puts the event in one partition. Each partition has copies on three brokers.

The controllers watch the brokers. They choose a leader for each partition.

Each consumer group reads the whole topic. The members of one group split the partitions between them. In the diagram, the "fraud-check" group has two consumers, and the "accounting" group has one.

বাংলা ব্যাখ্যা

Diagram-এ 3 বা তার বেশি broker-সহ একটি Kafka cluster দেখানো হয়েছে। একটি producer একটি topic-এ একটি event লেখে, এবং Kafka সেটি একটি partition-এ রাখে। প্রতিটি partition-এর copy তিনটি broker-এ থাকে।

Controller-গুলো broker-গুলোর ওপর নজর রাখে এবং প্রতিটি partition-এর জন্য একটি leader বেছে নেয়।

প্রতিটি consumer group পুরো topic পড়ে, আর একই group-এর member-রা partition-গুলো নিজেদের মধ্যে ভাগ করে নেয়। Diagram-এ "fraud-check" group-এ দুটি consumer আছে, আর "accounting" group-এ একটি।

The log: a notebook you can only add to

Think of a ship's logbook. The crew adds each line at the bottom, never erases a line, and numbers each line.

Kafka is built on the same idea, called a log. A new record goes only at the end. Nobody changes or deletes a single record. Source 1সোর্স 1 Each record gets a number called an offset. The offset always grows, so it shows the order of the records. Source 1সোর্স 1

Why this design? A hard disk is fast when it reads or writes one long run of data. It is slow when it must jump to many places. Source 1সোর্স 1 A log always writes at the end, so the disk works in its fast mode. To add a record takes the same short time, however long the log is, and needs no lock. Source 1সোর্স 1

A record is a key and a value, plus extra data such as the offset and a timestamp. The key is optional. Source 1সোর্স 1 Kafka sees the key and the value only as raw bytes, with no type. Source 1সোর্স 1 The producer turns its objects into bytes, which is called serialization. The consumer does the reverse. Source 1সোর্স 1

Kafka clients do not use HTTP. They speak Kafka's own protocol over TCP, so you need a Kafka client library, such as the Java producer and consumer classes. Source 1সোর্স 1

সহজ English

Kafka is built on a log, like a ship's logbook. A new record goes only at the end. Nobody changes or deletes a single record. Source 1সোর্স 1 Each record gets a number called an offset. The offset always grows, so it shows the order of the records. Source 1সোর্স 1

A hard disk is fast when it reads or writes one long run of data. It is slow when it must jump to many places. Source 1সোর্স 1 A log always writes at the end, so the disk stays in its fast mode. To add a record takes the same short time, however long the log is. It needs no lock. Source 1সোর্স 1

A record is a key and a value, plus extra data such as the offset and a timestamp. The key is optional. Source 1সোর্স 1 Kafka sees the key and the value only as raw bytes. Source 1সোর্স 1 The producer turns its objects into bytes (serialization), and the consumer does the reverse. Source 1সোর্স 1

Kafka clients do not use HTTP. They use Kafka's own protocol over TCP, so you need a Kafka client library. Source 1সোর্স 1

বাংলা ব্যাখ্যা

একটি জাহাজের logbook-এর কথা ভাবুন। Crew প্রতিটি নতুন লাইন নিচে যোগ করে, কোনো লাইন মোছে না, এবং প্রতিটি লাইনে নম্বর দেয়।

Kafka একই ধারণার ওপর তৈরি, যাকে log বলে। নতুন record শুধু শেষে যোগ হয়। কেউ কোনো একটি record বদলায় না বা মোছে না। Source 1সোর্স 1 প্রতিটি record একটি নম্বর পায়, যাকে offset বলে। Offset সবসময় বাড়ে, তাই এটি record-গুলোর ক্রম দেখায়। Source 1সোর্স 1

কেন এই design? Hard disk একটানা লম্বা data পড়তে বা লিখতে দ্রুত, কিন্তু অনেক জায়গায় লাফিয়ে যেতে হলে ধীর। Source 1সোর্স 1 Log সবসময় শেষে লেখে, তাই disk তার দ্রুত mode-এ কাজ করে। Log যত লম্বাই হোক, একটি record যোগ করতে একই অল্প সময় লাগে, এবং কোনো lock লাগে না। Source 1সোর্স 1

একটি record হলো একটি key ও একটি value, সঙ্গে offset ও timestamp-এর মতো অতিরিক্ত data। Key optional। Source 1সোর্স 1 Kafka key ও value-কে শুধু raw bytes হিসেবে দেখে, কোনো type ছাড়া। Source 1সোর্স 1 Producer তার object-গুলোকে bytes-এ রূপান্তর করে, একে serialization বলে। Consumer উল্টো কাজটি করে। Source 1সোর্স 1

Kafka client-গুলো HTTP ব্যবহার করে না। এগুলো TCP-র ওপর Kafka-র নিজস্ব protocol ব্যবহার করে, তাই আপনার একটি Kafka client library লাগবে, যেমন Java producer ও consumer class। Source 1সোর্স 1

Topics and partitions: shelves and drawers

Think of a library. Each subject has its own shelf. A very busy shelf is split into several drawers, so several librarians can work on it at the same time.

In Kafka, the shelf is a topic. A topic is a named stream of related records, like a table in a database. A cluster often has hundreds or thousands of topics. Source 1সোর্স 1 One machine cannot hold or serve a very big topic. So Kafka splits each topic into one or more partitions, and each partition is a separate log. Source 1সোর্স 1 This kind of split is called sharding.

A Kafka server is a broker, and all the brokers together are a cluster. A normal setup has three brokers or more. Source 1সোর্স 1 To grow, you add brokers. Each partition is a separate log, so the limit of the scale is the number of brokers that you can add. Source 1সোর্স 1 The article says that nothing in theory stops a cluster that takes 50 GiB/s of writes from growing to 100 GiB/s. Source 1সোর্স 1

সহজ English

Think of a library. Each subject has its own shelf. A very busy shelf is split into drawers, so several librarians can work on it at the same time.

In Kafka, the shelf is a topic. A topic is a named stream of related records, like a table in a database. A cluster often has hundreds or thousands of topics. Source 1সোর্স 1 One machine cannot hold or serve a very big topic. So Kafka splits each topic into one or more partitions. Each partition is a separate log. Source 1সোর্স 1 This kind of split is called sharding.

A Kafka server is a broker. All the brokers together are a cluster. A normal setup has three brokers or more. Source 1সোর্স 1 To grow, you add brokers. Each partition is a separate log, so the limit of the scale is the number of brokers that you can add. Source 1সোর্স 1 The article says that, in theory, nothing stops a cluster that takes 50 GiB/s of writes from growing to 100 GiB/s. Source 1সোর্স 1

বাংলা ব্যাখ্যা

একটি library-র কথা ভাবুন। প্রতিটি বিষয়ের নিজস্ব তাক আছে। খুব ব্যস্ত একটি তাক কয়েকটি drawer-এ ভাগ করা হয়, যাতে কয়েকজন librarian একসঙ্গে কাজ করতে পারেন।

Kafka-তে তাক হলো topic। Topic হলো সম্পর্কিত record-এর একটি নামযুক্ত stream, অনেকটা database-এর table-এর মতো। একটি cluster-এ প্রায়ই শত শত বা হাজার হাজার topic থাকে। Source 1সোর্স 1 একটি machine খুব বড় topic রাখতে বা serve করতে পারে না। তাই Kafka প্রতিটি topic-কে এক বা একাধিক partition-এ ভাগ করে, এবং প্রতিটি partition একটি আলাদা log। Source 1সোর্স 1 এই ধরনের ভাগকে sharding বলে।

একটি Kafka server হলো broker, আর সব broker মিলে একটি cluster। সাধারণ setup-এ তিনটি বা তার বেশি broker থাকে। Source 1সোর্স 1 বড় হতে চাইলে আপনি broker যোগ করেন। প্রতিটি partition আলাদা log, তাই scale-এর সীমা হলো আপনি কতগুলো broker যোগ করতে পারেন। Source 1সোর্স 1 Article বলে, তত্ত্বে 50 GiB/s write নেওয়া একটি cluster-কে 100 GiB/s পর্যন্ত বাড়তে কিছুই বাধা দেয় না। Source 1সোর্স 1

Copies, leaders, and controllers

Think of a kitchen. Only the head chef writes in the order book, and two assistants copy it. If the head chef gets sick, the manager names a new one.

Each partition has copies on several brokers. A setting called the replication factor sets the number of copies, and three is the usual value. Source 1সোর্স 1 Each copy is a replica. With three replicas, one broken disk does not lose data. Source 1সোর্স 1

One replica is the leader. Only the leader accepts new writes, and the followers copy from it. Reads can come from the leader or from a follower. Source 1সোর্স 1

Special brokers called controllers choose the leaders. A cluster usually has three controllers, and only one is active at a time. Source 1সোর্স 1 Every broker sends a heartbeat, a short "I am alive" message, to the active controller. If a broker sends no heartbeat for the session timeout (9 seconds by default, broker.session.timeout.ms), the controller fences it, which means it shuts that broker out. The controller then gives that broker's partitions new leaders. Source 1সোর্স 1

The controllers write each cluster decision to a special log, the __cluster_metadata topic. Every broker reads this log and replays it to build the same picture of the cluster. Source 1সোর্স 1 The controllers elect their own active leader with KRaft, a Kafka version of the Raft voting method. A change is final only when a majority of the controllers have stored it. Source 1সোর্স 1 Older Kafka versions used a separate system, ZooKeeper, for this job. Source 1সোর্স 1

সহজ English

Each partition has copies, called replicas, on several brokers. The replication factor setting sets the number of copies. Three is the usual value. Source 1সোর্স 1 With three replicas, one broken disk does not lose data. Source 1সোর্স 1 Only one replica, the leader, accepts new writes. The followers copy from it. Reads can come from the leader or a follower. Source 1সোর্স 1

Special brokers called controllers choose the leaders. A cluster usually has three controllers, and only one is active at a time. Source 1সোর্স 1 Every broker sends a short "I am alive" message (a heartbeat) to the active controller. If a broker sends no heartbeat for the session timeout (9 seconds by default, broker.session.timeout.ms), the controller shuts it out (fences it). Then the controller gives that broker's partitions new leaders. Source 1সোর্স 1

The controllers write each cluster decision to the __cluster_metadata topic. Every broker reads and replays this log to get the same picture of the cluster. Source 1সোর্স 1 The controllers elect their active leader with KRaft, a Kafka version of the Raft voting method. A change is final only when a majority of the controllers have stored it. Source 1সোর্স 1 Older Kafka versions used ZooKeeper for this job. Source 1সোর্স 1

বাংলা ব্যাখ্যা

একটি রান্নাঘরের কথা ভাবুন। শুধু head chef order book-এ লেখেন, আর দুজন সহকারী তা copy করেন। Head chef অসুস্থ হলে manager নতুন একজনকে বেছে নেন।

প্রতিটি partition-এর copy কয়েকটি broker-এ থাকে। Replication factor নামের একটি setting copy-র সংখ্যা ঠিক করে, এবং সাধারণ মান তিন। Source 1সোর্স 1 প্রতিটি copy একটি replica। তিনটি replica থাকলে একটি disk নষ্ট হলেও data হারায় না। Source 1সোর্স 1 একটি replica হলো leader। শুধু leader নতুন write গ্রহণ করে, আর follower-রা তার থেকে copy করে। Read leader বা follower, যেকোনোটি থেকে হতে পারে। Source 1সোর্স 1

Controller নামের বিশেষ broker-গুলো leader বেছে নেয়। একটি cluster-এ সাধারণত তিনটি controller থাকে, এবং একসময়ে শুধু একটি active থাকে। Source 1সোর্স 1 প্রতিটি broker active controller-কে heartbeat পাঠায়, অর্থাৎ একটি ছোট "আমি সচল আছি" message। কোনো broker session timeout (ডিফল্ট 9 সেকেন্ড, broker.session.timeout.ms) পর্যন্ত heartbeat না পাঠালে controller সেটিকে fence করে, অর্থাৎ বাইরে রাখে। তারপর controller সেই broker-এর partition-গুলোর জন্য নতুন leader ঠিক করে। Source 1সোর্স 1

Controller-গুলো cluster-এর প্রতিটি সিদ্ধান্ত একটি বিশেষ log-এ লেখে, __cluster_metadata topic-এ। প্রতিটি broker এই log পড়ে replay করে, যাতে সবাই cluster-এর একই ছবি পায়। Source 1সোর্স 1 Controller-গুলো KRaft দিয়ে নিজেদের active leader নির্বাচন করে। KRaft হলো Raft voting পদ্ধতির Kafka সংস্করণ। বেশিরভাগ controller কোনো পরিবর্তন store করলে তবেই তা চূড়ান্ত হয়। Source 1সোর্স 1 পুরোনো Kafka version-এ এই কাজের জন্য ZooKeeper নামের আলাদা system ব্যবহার হতো। Source 1সোর্স 1

Consumer groups and offsets: sharing the reading

Think of postal workers who share mail bags. Each worker notes the last letter done, so another worker can continue if one leaves.

A consumer group is a set of consumer programs that work as one team. Source 1সোর্স 1 Inside a group, only one consumer reads a partition at a time. This keeps the order correct without locks. Source 1সোর্স 1 Different groups read the same topic separately, each at its own speed. Source 1সোর্স 1

You can add or remove consumers while the group runs. To read faster, add consumers to the group. To give the same data to a new application, start a new group. Source 1সোর্স 1

The consumers of a group do not talk to each other. A broker called the group coordinator makes the decisions, and the consumers send it heartbeats. Source 1সোর্স 1 Each consumer saves its progress, the offset it has read up to, in a special topic called __consumer_offsets. This save is called a commit. Source 1সোর্স 1 If a consumer crashes, it or another consumer starts again from the last commit. Source 1সোর্স 1

সহজ English

Think of postal workers who share mail bags. Each worker notes the last letter done, so another worker can continue if one leaves.

A consumer group is a set of consumer programs that work as one team. Source 1সোর্স 1 Inside a group, only one consumer reads a partition at a time. This keeps the order correct without locks. Source 1সোর্স 1 Different groups read the same topic separately, each at its own speed. Source 1সোর্স 1

You can add or remove consumers while the group runs. To read faster, add consumers to the group. To give the same data to a new application, start a new group. Source 1সোর্স 1

The consumers of a group do not talk to each other. A broker called the group coordinator makes the decisions. The consumers send it heartbeats. Source 1সোর্স 1 Each consumer saves the offset that it has read up to in a special topic, __consumer_offsets. This save is a commit. Source 1সোর্স 1 If a consumer crashes, it or another consumer starts again from the last commit. Source 1সোর্স 1

বাংলা ব্যাখ্যা

ডাকের থলে ভাগ করে নেওয়া ডাককর্মীদের কথা ভাবুন। প্রত্যেকে শেষ কোন চিঠির কাজ করেছেন তা লিখে রাখেন, যাতে কেউ চলে গেলে অন্যজন সেখান থেকে চালিয়ে যেতে পারেন।

Consumer group হলো কিছু consumer program-এর একটি দল, যারা এক team হিসেবে কাজ করে। Source 1সোর্স 1 একটি group-এর ভেতরে একসময়ে শুধু একটি consumer একটি partition পড়ে। এতে lock ছাড়াই ক্রম ঠিক থাকে। Source 1সোর্স 1 আলাদা group-গুলো একই topic আলাদাভাবে, নিজের গতিতে পড়ে। Source 1সোর্স 1

Group চলার সময়ই আপনি consumer যোগ বা বাদ দিতে পারেন। দ্রুত পড়তে group-এ consumer যোগ করুন। নতুন application-কে একই data দিতে নতুন group শুরু করুন। Source 1সোর্স 1

একটি group-এর consumer-রা নিজেদের মধ্যে কথা বলে না। Group coordinator নামের একটি broker সিদ্ধান্ত নেয়, আর consumer-রা তাকে heartbeat পাঠায়। Source 1সোর্স 1 প্রতিটি consumer তার progress, অর্থাৎ কোন offset পর্যন্ত পড়েছে, __consumer_offsets নামের একটি বিশেষ topic-এ save করে। এই save-কে commit বলে। Source 1সোর্স 1 কোনো consumer crash করলে সেটি নিজে বা অন্য একটি consumer শেষ commit থেকে আবার শুরু করে। Source 1সোর্স 1

Retention and tiered storage: how long data stays

Think of a security camera that keeps the last 7 days of video, watched or not.

Some other message systems delete a message after a client reads it. Kafka does not. It keeps each message for a fixed time, often 7 days, and then deletes it. Source 1সোর্স 1 So a team can replay old data, for example after it fixes a bug in a consumer. Source 1সোর্স 1

Big clusters store a lot. At 1 GB/s of writes, 7 days of retention, and three copies, a cluster holds about 1,772 TiB. Source 1সোর্স 1 Tiered storage solves this. Kafka copies older data to a cloud object store such as Amazon S3. After a set time, for example 12 hours, the brokers delete their local copy. Source 1সোর্স 1 Consumers still read old data with the same API. The reads are a little slower, because the broker gets the data from S3. Source 1সোর্স 1 The article says that this makes the storage of large data more than 10 times cheaper. Source 1সোর্স 1

সহজ English

Think of a security camera that keeps the last 7 days of video, watched or not.

Some other message systems delete a message after a client reads it. Kafka does not. It keeps each message for a fixed time, often 7 days, and then deletes it. Source 1সোর্স 1 So a team can replay old data, for example after it fixes a bug in a consumer. Source 1সোর্স 1

Big clusters store a lot. At 1 GB/s of writes, 7 days of retention, and three copies, a cluster holds about 1,772 TiB. Source 1সোর্স 1 Tiered storage solves this. Kafka copies older data to a cloud object store such as Amazon S3. After a set time, for example 12 hours, the brokers delete their local copy. Source 1সোর্স 1 Consumers still read old data with the same API. These reads are a little slower, because the broker gets the data from S3. Source 1সোর্স 1 The article says that this makes the storage of large data more than 10 times cheaper. Source 1সোর্স 1

বাংলা ব্যাখ্যা

এমন একটি security camera-র কথা ভাবুন, যা video দেখা হোক বা না হোক, শেষ 7 দিনের video রাখে।

অন্য কিছু message system একটি client message পড়ার পর সেটি মুছে দেয়। Kafka তা করে না। এটি প্রতিটি message একটি নির্দিষ্ট সময়, প্রায়ই 7 দিন, রাখে এবং তারপর মুছে দেয়। Source 1সোর্স 1 তাই একটি team পুরোনো data আবার replay করতে পারে, যেমন একটি consumer-এর bug ঠিক করার পর। Source 1সোর্স 1

বড় cluster অনেক data রাখে। 1 GB/s write, 7 দিনের retention, এবং তিনটি copy হলে একটি cluster প্রায় 1,772 TiB রাখে। Source 1সোর্স 1 Tiered storage এই সমস্যার সমাধান করে। Kafka পুরোনো data Amazon S3-এর মতো একটি cloud object store-এ copy করে। একটি নির্দিষ্ট সময় পর, যেমন 12 ঘণ্টা, broker-গুলো তাদের local copy মুছে দেয়। Source 1সোর্স 1 Consumer-রা তখনও একই API দিয়ে পুরোনো data পড়ে। এই read একটু ধীর হয়, কারণ broker data S3 থেকে আনে। Source 1সোর্স 1 Article বলে, এতে বড় data store করা 10 গুণের বেশি সস্তা হয়। Source 1সোর্স 1

Exactly once: no lost and no double messages

Think of a bank that stamps a number on each cheque. If the same cheque comes in twice, the bank pays it only one time.

If a network loses a reply, the producer sends the message again, and that can make a duplicate. Kafka gives each message of a producer a growing number. If the same message comes again, the broker keeps only one copy. Source 1সোর্স 1 This property is called idempotency: to do an action twice has the same effect as to do it once.

Kafka also has transactions. A producer can write many messages to several topics and partitions. Then all of them are committed, or all of them are aborted. Source 1সোর্স 1 Consumers can be set to skip the messages of transactions that did not commit. Source 1সোর্স 1 When the input and the output are both in Kafka, this gives exactly-once processing. Source 1সোর্স 1 Duplicates can still come from outside systems, for example a web service that crashes after its write and gets a retry. Source 1সোর্স 1

সহজ English

Think of a bank that stamps a number on each cheque. If the same cheque comes in twice, the bank pays it only one time.

Sometimes the network loses a reply. Then the producer sends the message again, and that can make a duplicate. Kafka gives each message of a producer a growing number. If the same message comes again, the broker keeps only one copy. Source 1সোর্স 1 This is called idempotency: to do an action twice has the same effect as to do it once.

Kafka also has transactions. A producer can write many messages to several topics and partitions. The result is all or nothing: all of the messages are committed, or all of them are aborted. Source 1সোর্স 1 You can set consumers to skip the messages of transactions that did not commit. Source 1সোর্স 1 When the input and the output are both in Kafka, this gives exactly-once processing. Source 1সোর্স 1 Outside systems can still make duplicates. For example, a web service can crash after its write and then get a retry. Source 1সোর্স 1

বাংলা ব্যাখ্যা

এমন একটি bank-এর কথা ভাবুন, যা প্রতিটি cheque-এ একটি নম্বর দেয়। একই cheque দুবার এলে bank সেটির টাকা শুধু একবার দেয়।

Network কোনো reply হারিয়ে ফেললে producer message-টি আবার পাঠায়, এবং এতে duplicate তৈরি হতে পারে। Kafka একটি producer-এর প্রতিটি message-কে একটি ক্রমবর্ধমান নম্বর দেয়। একই message আবার এলে broker শুধু একটি copy রাখে। Source 1সোর্স 1 এই গুণকে idempotency বলে: একটি কাজ দুবার করলে একবার করার মতোই ফল হয়।

Kafka-তে transaction-ও আছে। একটি producer কয়েকটি topic ও partition-এ অনেক message লিখতে পারে। তারপর হয় সবগুলো commit হয়, নয়তো সবগুলো abort হয়। Source 1সোর্স 1 Consumer-দের এমনভাবে set করা যায়, যাতে commit না হওয়া transaction-এর message তারা skip করে। Source 1সোর্স 1 Input ও output দুটোই Kafka-তে থাকলে এতে exactly-once processing পাওয়া যায়। Source 1সোর্স 1 তবুও বাইরের system থেকে duplicate আসতে পারে, যেমন একটি web service তার write-এর পর crash করে এবং retry পায়। Source 1সোর্স 1

Key words

WordPlain meaning
Event (record, message)One fact that a program writes, such as "order 42 was paid"
ProducerA program that writes events to Kafka
ConsumerA program that reads events from Kafka
BrokerOne Kafka server
TopicA named stream of related events, like a table
PartitionOne slice of a topic, stored as its own log
OffsetThe number of an event inside a partition
ReplicaOne copy of a partition on one broker
Consumer groupA team of consumers that share the partitions of a topic
RetentionHow long Kafka keeps events before it deletes them

What a tester can learn

Tutorial advice

These ideas are the tutorial's own advice.

  • Stop one broker during a test run. Check that producers and consumers continue, and that no event is lost.
  • Kill a consumer before it commits its offset. Check that the next consumer processes the events again, and that your code handles the same event twice without harm.
  • Send events to one partition and check that they arrive in order. Do not expect one order across different partitions.
  • Send a message twice on purpose and check that the downstream result, such as a balance, changes only one time.
  • Measure consumer lag, the gap between the newest offset and the committed offset, under peak load.
  • Send a message with a broken shape, such as a missing field. Check that the consumer rejects it and does not crash.

সহজ English

These ideas are the tutorial's own advice.

  • Stop one broker during a test run. Check that producers and consumers continue, and that no event is lost.
  • Kill a consumer before it commits its offset. Check that the next consumer processes the events again. Check that your code handles the same event twice without harm.
  • Send events to one partition and check that they arrive in order. Do not expect one order across different partitions.
  • Send a message twice on purpose. Check that the downstream result, such as a balance, changes only one time.
  • Under peak load, measure consumer lag: the gap between the newest offset and the committed offset.
  • Send a message with a broken shape, such as a missing field. Check that the consumer rejects it and does not crash.

বাংলা ব্যাখ্যা

এগুলো tutorial-এর নিজস্ব পরামর্শ।

  • Test run চলার সময় একটি broker বন্ধ করুন। দেখুন producer ও consumer-রা কাজ চালিয়ে যায় এবং কোনো event হারায় না।
  • একটি consumer তার offset commit করার আগেই সেটিকে kill করুন। দেখুন পরের consumer event-গুলো আবার process করে, এবং আপনার code একই event দুবার পেলেও কোনো ক্ষতি ছাড়া সামলায়।
  • একটি partition-এ event পাঠান এবং দেখুন সেগুলো ক্রম অনুযায়ী আসে। আলাদা আলাদা partition-জুড়ে একটি ক্রম আশা করবেন না।
  • ইচ্ছা করে একটি message দুবার পাঠান। দেখুন downstream ফল, যেমন একটি balance, শুধু একবার বদলায়।
  • Peak load-এ consumer lag মাপুন, অর্থাৎ সবচেয়ে নতুন offset ও committed offset-এর মধ্যের ব্যবধান।
  • ভুল আকারের একটি message পাঠান, যেমন যাতে একটি field নেই। দেখুন consumer সেটি reject করে এবং crash করে না।

Reels on this topicএই টপিকের রিলস

Short videos from other creators, picked for this topic. They are not part of this page's fact-checked text. Nothing loads from YouTube until you press Play.অন্য ক্রিয়েটরদের বানানো ছোট ভিডিও, এই টপিকের জন্য বাছাই করা। এগুলো এই পেজের ফ্যাক্ট-চেক করা লেখার অংশ নয়। চালান বাটন চাপার আগে YouTube থেকে কিছুই লোড হয় না।

  1. [1]
    How Kafka Works

    The System Design Newsletter (Neo Kim) · accessed 2026-10-20দেখা হয়েছে: 2026-10-20