What Kafka is

Kafka records events in a log that keeps them after they're read, so producers and any number of consumers work independently, each at its own pace.

GazeekKAFKA FUNDAMENTALS: EVENT STREAMING·LESSON 1
LESSON 1

What Kafka is

Kafka records events in a log that keeps them after they're read, so producers and any number of consumers work independently, each at its own pace.

0:00 / 3:51

Diagrams in this video · 1Free in archhy

Copy and edit in archhy: One log, many readers (new tab)

The diagrams, full size

Copy any of them into archhy, free, and change it for your own system.

After this lesson you can

  • Say what an event is and what it carries
  • Explain why Kafka is a log, not a classic queue
  • Describe how producers and consumers stay decoupled
  • Name what people typically use Kafka for
Transcript

What Kafka is

Hi, Space Llama here. Welcome to Kafka Fundamentals. Today, the one big idea behind Kafka. Once it clicks, the rest of this course hangs off it. No code yet. Just one picture worth remembering.

Events, not requests

Most apps talk in requests. Do this, give me that, and wait for an answer. Kafka works with events instead. An event records that something happened. An order was placed. A payment cleared. Each event has a key, a value and a timestamp, plus optional headers for extra details. You'll also hear events called records, or messages. Same thing. Events with the same key stay together, in the order they were written. We'll see how in part two. Apps that write events are producers. Apps that read them are consumers.

One log, many readers

Here's the whole idea in one picture. An app on the left, a log in the middle, and three readers. The checkout app writes an event. Order placed, with a key, a value and a timestamp. The log keeps it, added to the end, after everything before it. Reading it later won't remove it. Each event in the log gets the next number, called its offset. This newest one is offset seven. Readers pull events at their own pace, and each one keeps its own place, its own offset. Email is up to date, reading the newest, seven. Analytics is slower, back at offset two. That's fine. A slow reader just falls behind, and catches up when it can. And since reading removes nothing, Fraud and Email and Analytics all get every event.

Queue or log?

So, is Kafka a queue? Everyone asks. In traditional messaging systems, a message is deleted once it's consumed. Read it, and it's gone. Kafka is a log. Events stay after they're read, until the topic's retention period removes them. So many readers can read the same data, each keeping track of its own place. Kafka can now do queue-style reading too, with something called share groups. We'll meet those in part four.

Decoupled by design

This is what people mean when they say Kafka decouples apps. Any number of producers can write to a topic, and any number of consumers can read it. Producers don't need to know who'll read their events. They just write to the topic. Consumers pull events when they're ready. A slow one falls behind on its own, without holding up anyone else. Need a new service tomorrow? Point it at the topic. The producers don't change at all.

What people use it for

So what do people actually use Kafka for? Activity tracking, for a start. Page views, searches and clicks become events on a topic. Log and metrics pipelines. Servers send their logs and monitoring data through Kafka, to wherever they're stored and watched. Event-driven microservices. Services react to each other's events, instead of calling each other and waiting. Change data capture. A connector turns each change in a database into an event, so other systems can keep up. And stream processing, where apps filter, join and count events as they arrive. You'll meet all of these again in this course.

Remember

Let's recap. An event records that something happened, with a key, a value and a timestamp. Kafka keeps events in a log. Reading them doesn't remove them. And every reader pulls at its own pace, so many apps can share the same data.

Practice and what's next

That's the big idea. Next lesson, Kafka and Confluent. What's open source, what's Confluent's, and what this course covers. See you there.

Gazeek Flash · free

Exam questions on your phone

Free questions on Start here: quick-fire batches and timed exams, on the web or Android.