Kafka 101 : Understanding Kafka Basics

Himanshu PandeyHimanshu Pandey
9 min read

✨ Before you dive in Kafka

Imagine if you didn’t have to wait around for someone to reply before getting on with your day.
You just do your part, make a quick announcement — and move on.
Anyone who needs to know can pick it up when they're ready.

That’s how event-based communication works. It’s like living in a world where everyone’s tuned in to the right signals, and no one’s left waiting.

🍕 When You’re the Producer:

You just baked a pizza.

Instead of calling each family member:

  • You ring the bell — “Pizza’s ready!”

  • Everyone who’s hungry hears it and comes to the kitchen

  • ✅ You don’t wait. You move on to cleaning up or watching TV.

📦 When You’re the Consumer:

You're waiting for a delivery.

Instead of checking the front door every 10 minutes:

  • You relax.

  • The doorbell rings when the package arrives.

  • You get up, grab it, and carry on.

✅ You didn’t waste time waiting. You just reacted when the event happened.

🧠 Real-World Impact

You don’t constantly check, call, or coordinate.
You just send signals. Listen for signals. And act when it’s your turn.

That’s the power of event-driven systems.
That’s what Kafka makes possible — in tech and in life.

Visualise Kafka with Real Life Analogy


🔄 #1 : A Busy Post Office

In a small town:

  • People write letters (information)

  • They drop them into the mailbox (a central place)

  • The post office picks them up, sorts them, and delivers them to whoever needs them — maybe a person, a business, or even multiple recipients.

No one needs to call ahead. You just post it and trust the system.

🚫 Now Imagine the Town Without a Post Office

  • You’d have to personally deliver every letter.

  • If your friend wasn’t home, you’d have to try again later.

  • You’d need to know everyone’s address and timing.

  • If you needed to tell multiple people something, you’d go door to door.

It would be chaotic, slow, and error-prone — especially in a growing town.

Kafka Is Like a Post Office for Software

In a digital system:

  • Apps write messages (letters) and drop them into Kafka (mailbox).

  • Kafka stores, sorts, and delivers those messages to whoever asked for them (other apps or systems).

  • Everyone can work independently, without calling each other directly.

  • Messages don’t get lost — they’re delivered, stored, and can be replayed later if needed.


🔄 #2 : Airport Announcements

At an airport:

  • When a gate change or delay is announced, everyone listening gets the update at once.

  • The airline doesn’t go to each passenger individually.

  • People hear what’s relevant and act on it.

Kafka works the same way — it broadcasts events, and different parts of your system respond only if it’s relevant to them.


So What is Kafka ?

Apache Kafka is an open-source platform used to stream data in real time between different parts of a system.
Think of it like a central nervous system for your software — it lets apps talk to each other by sending messages/events.

Simply put, Kafka is a platform for:

  • Publishing events (like user signup, payment done)

  • Subscribing to events (like sending confirmation emails)

  • Streaming data between services in real time

  • Storing events safely for future use

💡 Why Was Kafka Needed?

Before Kafka, systems:

  • Had to call each other directly (like going door to door)

  • Would break if one system was slow or unavailable

  • Couldn’t handle high volume or real-time needs

Kafka fixed this by introducing:

  • One central hub for communication

  • Speed, reliability, and independence

  • A way to go back in time and see what happened

🏗️ Real-World Example: Kafka in Digital Banking

  • User signs up → Event user.created is published

  • Notification Service reads the event → Sends welcome SMS

  • Audit Service reads the same event → Logs it for compliance

  • Analytics Engine reads the event → Updates real-time dashboard

All these happen without any direct API calls between services.

Key Terminology:

  • Service

  • Producer

  • Consumer

  • Kafka Broker

  • Kafka Topic

  • Subscribe to a Topic

💼 Service

A software application or microservice that performs a specific job.

🔧 Example: A User Service creates accounts. A Payment Service processes payments.
It can produce, consume, or both in a Kafka setup.


✉️ Producer

A program or service that sends messages (events) to Kafka.

🧠 Think: “I have something to say.”
E.g., User Service sends a user.created event to Kafka.


👂 Consumer

A program or service that reads messages from Kafka.

🧠 Think: “I’m listening for updates.”
E.g., Notification Service listens for user.created events to send welcome emails.


🏣 Kafka Broker

The central server in Kafka that stores and delivers messages.

🧠 Think: Like a smart post office — it holds all the messages and makes sure consumers get them reliably.


🗂 Kafka Topic

A named category where Kafka messages are stored and grouped.

🧠 Think: A folder or mailbox for a specific type of event, like user.created, payment.successful, or order.cancelled.


📬 Subscribe to a Topic

A consumer’s way of saying: “Give me all messages from this topic.”

🧠 Example: Notification Service subscribes to the user.created topic
→ Kafka gives it every new user signup event.

Here’s Simple and Clear mapping of Kafka terms to the two analogies we’ve been using: 

Post Office and Airport Announcements. 

This will help solidify your understanding with real-world visuals:

📮 POST OFFICE Analogy

Kafka TermPost Office Equivalent
ServiceA person or business sending/receiving letters
ProducerSomeone mailing a letter
ConsumerSomeone checking their mailbox and reading letters
Kafka BrokerThe post office — collects, sorts, delivers mail
Kafka TopicA specific mailbox for a category of letters (e.g., “Bills”)
Subscribe to TopicTelling the post office: “Give me all the bills that come in”

📝 Example:

  • Turtle Bank (Service) produces an event: "New account opened" → drops a message into the Accounts topic

  • Notification Service subscribes to that topic → gets the message and sends a welcome SMS


✈️ AIRPORT ANNOUNCEMENT Analogy

Kafka TermAirport Announcement Equivalent
ServiceAn airline, passenger app, or airport system
ProducerThe gate agent making an announcement
ConsumerPassengers listening for updates
Kafka BrokerThe PA system that broadcasts the announcement
Kafka TopicThe speaker channel for a specific flight or gate
Subscribe to TopicTuning in to the specific gate or flight you care about

📝 Example:

  • Airline staff announces: “Flight QF101 now boarding” on gate speakers (Topic = flight.qf101.status)

  • Passengers and airport apps that subscribed to that flight instantly receive the update and react


🎯 Quick Summary Table

Kafka TermPost OfficeAirport Announcement
ServicePerson or businessAirline or Airport App
ProducerLetter senderAnnouncement speaker
ConsumerLetter receiverPassenger hearing the info
Kafka BrokerPost officePA speaker system
Kafka TopicSpecific mailboxSpecific flight channel
SubscribeAsk for mail of a typeTune into a flight update

Relationships ( Service, Broker & Topic )

Let’s break down the relationship between Service, Topic, Event, Broker, Producer, and Consumer in simple terms with a real-world analogy and a technical perspective.

🧩 Real-World Analogy: Town Radio Station

Imagine a town with:

  • Several people making announcements (Producers)

  • A radio station (Kafka Broker)

  • Each topic has its own radio channel (Kafka Topic)

  • Several tuned-in listeners (Consumers)


🔗 Key Terms & Relationships (Simplified)

TermDescriptionIn Our Radio Analogy
ServiceA microservice (e.g., Payment, Notification, Fraud) that performs a business functionA citizen or department
EventA fact or activity that has happened (e.g., user.created, txn.initiated)A town announcement
ProducerA service that generates/sends eventsThe person making the announcement
TopicA named category for events (e.g., card.blocked, loan.check.requested)The specific radio channel
Kafka BrokerA distributed system that stores and delivers events published to topicsThe central radio station broadcasting to all
ConsumerA service that subscribes to a topic and reacts to eventsperson tuned into a radio channel and listening

🔄 Recap: Relationships

  • A Service can act as both Producer and Consumer

  • A Producer sends Events to a Topic via a Kafka Broker

  • A Consumer subscribes to a Topic and reacts to incoming Events

  • The Kafka Broker acts as a smart middleman, ensuring durability, ordering, and distribution

🧾 User Journey: Making a Payment (End-to-End View with Kafka)

Let’s put it all together to understand a Payment user journey for payment made through an Digital Banking App implemented using event-based architecture

Same workflow explained via sequence diagram:

The sequence diagram version of the Kafka event flow for Sarah’s payment:

  • It shows the flow from the user action, through Payment Service, to Kafka, and out to all consumer services.

  • Each message and system action is shown in order, making it ideal for technical walkthroughs or architectural documentation.

👩‍💼 Step 1: User Makes a Payment

  • A customer, Sarah, opens her banking app and pays her electricity bill.

  • She taps "Pay Now."

🛠 Step 2: Payment Service kicks in

  • The Payment Service receives the request.

  • It starts processing: checks the amount, balance, and receiver.

  • As soon as it begins, it generates an event called txn.initiated.

✉️ Step 3: Producer sends the event to Kafka

  • Inside the Payment Service, a Producer component packages the message:

      {
        "type": "txn.initiated",
        "userId": "sarah123",
        "amount": 150,
        "timestamp": "2025-05-23T10:32:00Z"
      }
    
  • It sends this to Kafka under the topic txn.initiated.

🗂 Step 4: Kafka Topic & Broker handle the event

  • Kafka receives the event and stores it in the txn.initiated topic.

  • The Kafka Broker:

    • Safely stores the message

    • Keeps track of which consumers have read it

    • Makes it available instantly to anyone subscribed

📥 Step 4.5: Services Subscribe to the Topic

Before any message can be delivered, each consumer service must subscribe to the topic.
This means:

  • Notification Service subscribes to txn.initiated

  • Fraud Detection, Analytics Engine, and Audit Service also subscribe

By subscribing, they’re saying:

“Hey Kafka, let me know whenever something new happens on this topic.”

Kafka will now automatically deliver new messages to each service as soon as they’re available.

📡 Step 5: Multiple Services (Consumers) React

All of these services are listening to the txn.initiated topic and act independently:

ConsumerAction
Notification ServiceSends Sarah an SMS: “Your payment of $150 is being processed.”
Fraud DetectionChecks if the amount/location is suspicious
Analytics EngineUpdates real-time dashboard with new transaction stats
Audit ServiceLogs the transaction for compliance and history

Hope, this gives an basic overall understanding of Kafka and it’s nuts and bolt. Next we’ll do a deep dive by looking an Sample Banking Application

0
Subscribe to my newsletter

Read articles from Himanshu Pandey directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Himanshu Pandey
Himanshu Pandey