Latest / CyberSecurity Summary / pache Kafka in Action: From basics to production
Transcript
- 0:00Speaker 1: Welcome to the deep dive, your shortcut to truly understanding
- 0:03Speaker 1: complex topics. Today, we're plunging into Apache Koffka. It's really
- 0:09Speaker 1: a foundational technology underpinning so much of the modern data world.
- 0:14Speaker 2: Absolutely, it's everywhere, even if you don't see it directly.
- 0:16Speaker 1: We've pulled together a stack of detailed sources for you,
- 0:19Speaker 1: particularly some really great insights from a patchi Kofka in action,
- 0:24Speaker 1: and our mission really is to unpack its full potential.
- 0:27Speaker 2: Yeah, get beyond just the buzzwords exactly.
- 0:29Speaker 1: We'll explore everything from its basic building blocks to how
- 0:33Speaker 1: it ensures rock solid reliability, which is critical goose performance
- 0:37Speaker 1: to incredible levels, and fits into the most advanced enterprise systems.
- 0:42Speaker 1: Think of it this way. If you've ever wondered how
- 0:44Speaker 1: a massive online retailer processes millions of real time orders,
- 0:48Speaker 1: updates inventory instantly, or personalizes your shopping experience on the fly, Kuffa.
- 0:53Speaker 2: Is probably in the mix somewhere. It's off in that
- 0:55Speaker 2: silent powerhouse.
- 0:56Speaker 1: Get ready for some serious aha moments, because this deep
- 1:00Speaker 1: dive is your essential guide. We want you to not
- 1:03Speaker 1: just know what Kolica is, but deeply understand how it
- 1:07Speaker 1: works and why it's so critical for today's real time
- 1:10Speaker 1: data needs.
- 1:11Speaker 2: And hopefully, without feeling overwhelmed by the jargon.
- 1:13Speaker 1: Let's untack this.
- 1:14Speaker 2: It's truly a system that transforms how organizations handle data.
- 1:19Speaker 2: It enables that shift, you know, from waiting.
- 1:21Speaker 3: For daily reports still a batch world.
- 1:24Speaker 2: Right to getting instant insights and acting on them immediately.
- 1:27Speaker 1: That real time capability is absolutely where the magic happens. Okay,
- 1:31Speaker 1: So for anyone looking to understand Kafka, where do we
- 1:34Speaker 1: even begin? What are its absolute foundational elements?
- 1:38Speaker 2: Okay? So at its core, cof Go works with messages
- 1:42Speaker 2: sometimes called records. Okay, These are essentially just by rays.
- 1:45Speaker 2: Think of them like small data envelopes, and for efficiency,
- 1:49Speaker 2: they're often grouped into batches before being sent saves overhead.
- 1:52Speaker 1: Got it? Batches of messages, and these messages are organized
- 1:55Speaker 1: into topics like categories exactly.
- 1:59Speaker 2: Think of a topic as a dedicated channel or category
- 2:02Speaker 2: for bundling messages of a specific business type, much like
- 2:06Speaker 2: tables in a database maybe, but really designed for a
- 2:09Speaker 2: continuous stream of events. So, for that online retailer we mentioned,
- 2:12Speaker 2: you might have a customer orders topic or maybe a
- 2:15Speaker 2: product inventory updates topic.
- 2:17Speaker 1: Right, So if I place an order that becomes a
- 2:20Speaker 1: message in the customer orders topic. Simple enough, But how
- 2:23Speaker 1: does KOFKA handle the sheer volume millions, maybe billions of
- 2:27Speaker 1: messages and ensure it can scale.
- 2:30Speaker 2: Ah? That's where partitions come in, and they are truly
- 2:33Speaker 2: like the backbone of kofka's performance and scalability.
- 2:36Speaker 1: Partitions Okay, hash.
- 2:38Speaker 2: Topic is divided into one or more partitions. This division
- 2:41Speaker 2: is what enables parallel processing lots of things happening at once.
- 2:44Speaker 1: Makes sense, divide and conquer and to.
- 2:46Speaker 2: Ensure high availability and fault tolerance, which is crucial. These
- 2:49Speaker 2: partitions are replicated across different COFCA servers. The servers which
- 2:53Speaker 2: you call we call them brokers. So if one broker
- 2:55Speaker 2: goes down to debta, is safe and accessible in another one?
- 2:58Speaker 2: No panic?
- 2:59Speaker 1: Got it? Mess topics partitions on brokers. Okay, So you
- 3:03Speaker 1: have producers sending messages and consumers receiving them. How did
- 3:07Speaker 1: they interact with these partitions and brokers?
- 3:10Speaker 2: Good question. Producers are the application sending the messages your
- 3:14Speaker 2: order service. Maybe they send them to the designated leader
- 3:18Speaker 2: of a partition.
- 3:19Speaker 1: Leader one broker is in charge for that partition, right, and.
- 3:22Speaker 2: The producer selects that partition using something called a partitioner.
- 3:26Speaker 2: Often it's based on a message key, which we'll get to.
- 3:28Speaker 1: Okay.
- 3:29Speaker 2: On the other side, consumers receive and process messages. They're
- 3:32Speaker 2: quite flexible actually, they can read from multiple partitions, even
- 3:36Speaker 2: multiple topics at once.
- 3:37Speaker 1: And the brokers themselves, what's their main job.
- 3:39Speaker 2: The brokers are the Kafka servers. They manage the storage, distribution,
- 3:43Speaker 2: retrieval of messages, all that, and they share replicas and
- 3:47Speaker 2: processing tasks pretty evenly among themselves. It's a distributed system.
- 3:51Speaker 1: This sounds like a lot of moving parts all needing
- 3:53Speaker 1: to coordinate. Who is the leader? Is this broker alive?
- 3:56Speaker 1: How does Kafka manage that internal choreography?
- 3:59Speaker 2: Right? That's the role coordination pluster. Historically this was a
- 4:02Speaker 2: page zookeeper, a whole separate system you had to manage.
- 4:05Speaker 1: I remember a zoo keeper could be complex.
- 4:08Speaker 2: It could. But now Koka is increasingly moving to craft
- 4:12Speaker 2: kr aft ok and this isn't just a name change.
- 4:15Speaker 2: It's a pretty significant evolution. Craft simplifies the entire Kofka
- 4:21Speaker 2: architecture because it removes that external dependency on zookeeper, so
- 4:26Speaker 2: Kofka manages itself more exactly, it becomes self managing for
- 4:30Speaker 2: these critical coordination tasks. Overseeing partition assignments, handling leader elections,
- 4:35Speaker 2: continuously monitoring broker health means fewer moving parts for you
- 4:39Speaker 2: to manage, which is a huge operational win, especially for
- 4:42Speaker 2: large dynamic clusters.
- 4:43Speaker 1: Okay, that gives us the basic anatomy messages and topics
- 4:47Speaker 1: split into partitions managed by brokers, with producers and consumers
- 4:51Speaker 1: all coordinated by craft or zookeeper. But here's where it
- 4:54Speaker 1: gets really interesting and a bit well mind bending for me. Initially,
- 4:58Speaker 1: the sources describe Kofka's core nature as a distributed log.
- 5:02Speaker 2: Yes, this is fundamental.
- 5:04Speaker 1: Can you elaborate on that? Why is thinking of it
- 5:05Speaker 1: as a log so important?
- 5:07Speaker 2: Absolutely? What's truly fascinating here is that Kafka is fundamentally
- 5:11Speaker 2: a distributed log. You need to sort of forget about
- 5:15Speaker 2: it being just a message queue for a second. Okay,
- 5:17Speaker 2: think of it more like an immutable personal diary, or
- 5:20Speaker 2: maybe better the commit log of a database. It answers
- 5:23Speaker 2: the question what happened? It focuses on the history of
- 5:26Speaker 2: events rather than just what is which is the current state?
- 5:30Speaker 1: Right history versus snapshot?
- 5:32Speaker 2: Precisely So for our online retailer, it's not just current
- 5:35Speaker 2: inventory is fifty shirts. It's more like a shirt was
- 5:38Speaker 2: sold at ten point zero one am than another at
- 5:42Speaker 2: ten point zero two am. Then we receive stock at
- 5:45Speaker 2: ten point zero five am, the whole sequence.
- 5:47Speaker 1: So it's about the sequence of actions, the journey, not
- 5:50Speaker 1: just the final destination. What are the key properties of
- 5:53Speaker 1: such a log that make it so powerful?
- 5:55Speaker 2: Logs have distinct crucial properties. First order and sorting. Messages
- 5:59Speaker 2: are always sorted time within a partition, oldest entry.
- 6:01Speaker 1: The beginning partition, got it.
- 6:03Speaker 2: Second, writing and reading direction. You always append new entries
- 6:06Speaker 2: to the end of the log, like adding to a diary,
- 6:08Speaker 2: and you typically read from old to new using what
- 6:10Speaker 2: Kafka calls offsets to track your position.
- 6:13Speaker 1: Offsets like bookmarks kinda yeah.
- 6:15Speaker 2: And crucially, immutability. Once an entry is written, you can't
- 6:19Speaker 2: easily change or remove it. It's like writing in permanent ink.
- 6:22Speaker 1: That immutability has profound implications for data integrity. I imagine,
- 6:27Speaker 1: and I've heard this concept of time travel mentioned with logs.
- 6:30Speaker 1: How does that actually work and why is it such
- 6:32Speaker 1: a game changer?
- 6:33Speaker 2: That's right, time travel because the log is immutable and ordered.
- 6:38Speaker 2: You can literally reconstruct the state of the world at
- 6:40Speaker 2: any point in time by simply replaying the entries from
- 6:43Speaker 2: the beginning of the log or from a specific offset.
- 6:47Speaker 2: For our online retailer, this means you could replay all
- 6:50Speaker 2: order placed events from last year to reconstruct exactly how
- 6:53Speaker 2: many items were sold during a specific promotion wow, or
- 6:57Speaker 2: even rebuild an entire system state if a database with
- 6:59Speaker 2: some lost just from the Kofka log. This capability is
- 7:04Speaker 2: really how Kafka helps businesses transition from traditional batch oriented
- 7:08Speaker 2: processing you know, waiting for those overnight reports.
- 7:11Speaker 1: Right at the end of day summary is to real.
- 7:12Speaker 2: Time data handling, getting instant, up to the minute insights.
- 7:15Speaker 1: That's incredibly powerful replaying history. But if a log is
- 7:19Speaker 1: conceptually simple, why does it need to be distributed? Why
- 7:22Speaker 1: not just one gigantic, super fast log on one machine. Yeah,
- 7:26Speaker 1: good question, And this feels like where Kofka truly transforms
- 7:30Speaker 1: from a concept into an industrial strength powerhouse. Must have
- 7:34Speaker 1: big implications for like data resilience exactly.
- 7:37Speaker 2: The challenge with the single log is clear speed, scalability
- 7:41Speaker 2: and resilience a single system, a single server. It's often
- 7:46Speaker 2: just not reliable enough hardware fails networks glitch, it's common.
- 7:51Speaker 2: Kafka addresses this through horizontal scaling. Me Instead of buying bigger,
- 7:55Speaker 2: more powerful servers, vertical scaling you use more servers. When
- 7:58Speaker 2: you're existing brokers are getting busy, you just add another
- 8:00Speaker 2: one to the cluster.
- 8:02Speaker 3: Scale out, not up precisely.
- 8:04Speaker 2: This is cheaper, much more flexible, and fits the reality
- 8:07Speaker 2: that individual machines aren't perfectly reliable.
- 8:09Speaker 1: So that's a fundamental architectural philosophy behind COFKA. Expect failures,
- 8:13Speaker 1: build around them.
- 8:14Speaker 2: It absolutely is. This approach is crucial because individual IT
- 8:17Speaker 2: systems are seen as inherently unreliable. Horizontal scaling also enables parallelization.
- 8:23Speaker 1: More work done at the same time.
- 8:24Speaker 2: Right, allowing Kofka to process far more messages per unit
- 8:29Speaker 2: of time than a single server ever could. And this
- 8:32Speaker 2: works sufficiently because in KOFKA, data for one logical entities,
- 8:37Speaker 2: say all events related to a specific product or maybe
- 8:41Speaker 2: a single customer's order history can be kept in its
- 8:44Speaker 2: own log partition.
- 8:45Speaker 1: Using that message key you mentioned earlier.
- 8:47Speaker 2: Exactly using the key, this ensures correct ordering for that
- 8:51Speaker 2: specific entity, even if the overall order across all products
- 8:54Speaker 2: isn't strictly sequential globally.
- 8:56Speaker 1: Okay, that makes sense order within a context.
- 8:58Speaker 2: So the implication for you, as someone listening and maybe
- 9:01Speaker 2: trying to build robust systems, is that Kofka is designed
- 9:04Speaker 2: from the ground up to be highly available and resilient
- 9:07Speaker 2: even if parts of it fail. It distributes data and
- 9:10Speaker 2: work across many machines. It's built for reliability in an
- 9:14Speaker 2: unreliable world.
- 9:15Speaker 1: That's a fantastic overview of the core architecture, very clear.
- 9:18Speaker 1: Let's maybe talk about the messages themselves. Now. The source
- 9:20Speaker 1: mentions Kofka's data agnosticism. What does that actually mean for
- 9:24Speaker 1: what you can send through it?
- 9:25Speaker 2: It means Kafka doesn't really care about the content of
- 9:28Speaker 2: your messages. It treats all messages as raw BTE arrays.
- 9:32Speaker 1: Just sequences of bytes yep.
- 9:34Speaker 2: This flexibility is a key design choice. It allows Kafka
- 9:38Speaker 2: to handle any kind of data, whether it's JSON, AVRO
- 9:41Speaker 2: proto buff, plaintext, whatever, regardless of its format or structure.
- 9:46Speaker 2: It doesn't try to interpret the data, which is actually
- 9:48Speaker 2: a big part of its high performance.
- 9:50Speaker 1: Like a postal service.
- 9:51Speaker 2: Exactly like a postal service that delivers any package, big
- 9:54Speaker 2: or small without needing to know what's inside.
- 9:56Speaker 1: That sounds incredibly flexible, But doesn't that mean it's complete
- 10:00Speaker 1: agnostic to the meaning or structure of the data. What
- 10:03Speaker 1: are the implications of that for say, data governance or
- 10:07Speaker 1: ensuring consistency down the line.
- 10:09Speaker 2: Ah, you've hit on a crucial point there. While Kofka
- 10:13Speaker 2: itself is agnostic, in practice, it is optimized for many
- 10:16Speaker 2: small structured messages.
- 10:18Speaker 1: Small unstructure.
- 10:19Speaker 2: Okay, the default maximum message size is only one megabyte.
- 10:22Speaker 1: Oh, that's smaller than I might have thought.
- 10:24Speaker 2: It is, and why you can technically adjust this. It's
- 10:27Speaker 2: generally advised against larger messages can severely impact performance disk space.
- 10:34Speaker 2: It's just not what it's designed for. Kofka is built
- 10:36Speaker 2: for high throughput of many small events, not for transferring
- 10:40Speaker 2: large files like PDFs or big video files. I mean,
- 10:43Speaker 2: look at LinkedIn. They famously use Kafka to process something
- 10:46Speaker 2: like seven trillion messages a day across roughly one hundred
- 10:49Speaker 2: clusters back in twenty nineteen.
- 10:51Speaker 1: Seven trillion a day.
- 10:53Speaker 2: That's an astonishing number of small messages. Really drives home
- 10:56Speaker 2: the point definitely.
- 10:57Speaker 1: So if most messages are small, what are the common
- 11:00Speaker 1: types of messages you typically see in a real world
- 11:03Speaker 1: KOFCA system, what patterns emerge in practice?
- 11:06Speaker 2: Most systems use a mix of message types. You often
- 11:08Speaker 2: see states, states, yeah, messages that describe the complete current
- 11:12Speaker 2: state of an object, like all the details for a product,
- 11:15Speaker 2: its current price, stock level, description, everything, and if you
- 11:18Speaker 2: only care about the latest state. KOFKA has a feature
- 11:20Speaker 2: called log compaction, which uses message keys to save space
- 11:24Speaker 2: by keeping only the most recent version of a particular record.
- 11:27Speaker 1: Okay, so state is the full picture right now? What else?
- 11:30Speaker 2: Then? There are deltas. These contain only the changes in state,
- 11:33Speaker 2: like just a stock quantity adjustment of negative five because
- 11:36Speaker 2: an item sold or plus ten because stock arrived.
- 11:40Speaker 1: Ah, just the change. That sounds way more efficient for
- 11:42Speaker 1: data volume.
- 11:43Speaker 2: It is much smaller messages, but they're less useful on
- 11:47Speaker 2: their own.
- 11:48Speaker 1: How so, what are the challenges if you only have
- 11:50Speaker 1: deltas and need to know, say, the product's total stock
- 11:55Speaker 1: right now?
- 11:55Speaker 2: That's a great question. If you only have deltas, you'd
- 11:57Speaker 2: have to process all previous deltas for that product just
- 12:01Speaker 2: to reconstruct the current state. That could be computationally intensive
- 12:04Speaker 2: for the consumer.
- 12:05Speaker 1: Right you have to sum them all up exactly.
- 12:07Speaker 2: Which is why events are often preferred. They describe what happened,
- 12:10Speaker 2: but add context. Like instead of just MIGHTO five stock,
- 12:14Speaker 2: the event might be order fulfilled event, which contains the
- 12:17Speaker 2: stock change but also the order ID, customer ID timestamp
- 12:21Speaker 2: more more meaning VAT, adjustment or promotion started, or other examples. Logs,
- 12:27Speaker 2: in fact, are really just a special kind of event stream.
- 12:29Speaker 1: Okay, events give context and you mentioned one more type.
- 12:32Speaker 2: Yes, commands. These are used to instruct other systems to
- 12:35Speaker 2: perform actions like ship this order command or process payment command.
- 12:40Speaker 2: Unlike events, where the cener often doesn't care who listens,
- 12:43Speaker 2: commands usually require a response or a specific action from
- 12:47Speaker 2: the recipient system.
- 12:48Speaker 1: That distinction between events and commands feels important. Commands expect
- 12:53Speaker 1: a reaction. Now you mentioned, messages aren't just a singular
- 12:57Speaker 1: blob of data. They have structure. Break that down for
- 13:00Speaker 1: us again. What are the parts of a Kafka message?
- 13:03Speaker 2: Yes, a Kafka message or record technically is composed of
- 13:07Speaker 2: a few key elements. First, the value that's the primary payload,
- 13:12Speaker 2: the actual information you want to convey, like the details
- 13:14Speaker 2: of a customer order.
- 13:15Speaker 3: Usually the biggest part the core data.
- 13:17Speaker 2: And there's an optional key which is incredibly important even
- 13:21Speaker 2: though it's optional, so important it's used to categorize messages,
- 13:24Speaker 2: and critically, messages with the same key are guaranteed by
- 13:27Speaker 2: Kafka to go to the same partition.
- 13:29Speaker 1: Ah. So that's how you ensure order for a specific entity,
- 13:32Speaker 1: like all updates for product one two over.
- 13:34Speaker 2: Exactly, if you send all updates for product one twenty
- 13:37Speaker 2: three with a key one twenty three, they land in
- 13:40Speaker 2: the same partition in order, it guarantees their order relative
- 13:43Speaker 2: to each other, at least from a single producer. The
- 13:46Speaker 2: key is also essential for that log compaction feature we
- 13:49Speaker 2: mentioned where Kafka retains only the latest message for a
- 13:53Speaker 2: given key, very useful for topics representing current state.
- 13:56Speaker 1: So the key is crucial for ordering and compaction, not
- 13:59Speaker 1: just as a ID. What else is in a message?
- 14:02Speaker 2: There are also optional custom headers. These are meant for
- 14:05Speaker 2: technical metadata, things like tracing IDs for distributed systems, maybe
- 14:09Speaker 2: security token stuff like that, not really for business data.
- 14:12Speaker 1: Keep business data in the value generally yes.
- 14:14Speaker 2: And finally, there's a timestamp. This records the time the
- 14:17Speaker 2: message was created by the producer or potentially when it
- 14:20Speaker 2: was appended to the broker log, depending on configuration. This
- 14:23Speaker 2: timestamp is vital for many real time analytics scenarios, especially
- 14:27Speaker 2: when you start dealing with time windows in stream processing.
- 14:30Speaker 1: Fascinating how much detail goes into what seems like a
- 14:33Speaker 1: simple message. Loads of potential there. Now, let's pivot to
- 14:38Speaker 1: something absolutely critical for any data system, reliability. How does
- 14:43Speaker 1: kofka build trust with your data? How does it ensure
- 14:45Speaker 1: nothing gets lost or hopelessly out of order?
- 14:49Speaker 2: Right? Reliability in Kofka is built on a few core pillars. First,
- 14:53Speaker 2: replication and leaders followers.
- 14:55Speaker 1: We touched on this leaders and followers for partitions exactly.
- 14:58Speaker 2: For each partition, one broker acts as the leader. It
- 15:02Speaker 2: handles all the incoming produce requests and outgoing consumer requests
- 15:06Speaker 2: for that partition. The other brokers holding replicas for that
- 15:09Speaker 2: partition are called followers, and they just continuously replicate or
- 15:12Speaker 2: copy new messages from that leader. This creates redundant copies
- 15:16Speaker 2: of your data across different machines.
- 15:18Speaker 1: That sounds incredibly robust, multiple copies, But what actually happens
- 15:22Speaker 1: behind the scenes when a leader fails let's say the
- 15:24Speaker 1: machine crashes. Is the switch to a follower instantaneous? Are
- 15:28Speaker 1: there any potential downsides or edge cases? A listener should be.
- 15:31Speaker 2: Aware of good question. When a leader fails, Kafka automatically
- 15:35Speaker 2: detects this and elects a new leader from its set
- 15:38Speaker 2: of in sync replicas or ISRs. These are followers that
- 15:42Speaker 2: are caught up with a leader's.
- 15:43Speaker 1: Log ISRs, in sync replicas.
- 15:45Speaker 2: YEAH, or sometimes eligible leader replicas elrs, depending on the setup.
- 15:50Speaker 2: The goal is to ensure the topic remains accessible. Producers
- 15:54Speaker 2: and consumers are designed to automatically detect this change and
- 15:57Speaker 2: switch to the new leader, usually with minimal interruption. We're
- 16:00Speaker 2: talking milliseconds typically.
- 16:02Speaker 1: Okay, so it's fast. Any downsides?
- 16:04Speaker 2: The main downside is that during that brief election period,
- 16:07Speaker 2: that specific partition might be temporarily unavailable for writing. Reading
- 16:12Speaker 2: might still be possible from followers depending on config, but
- 16:15Speaker 2: writs need the leader. Also, once the original preferred leader
- 16:19Speaker 2: comes back online and catches up, KAKA often aims to
- 16:22Speaker 2: reinstate it as leader. This helps rebalance the leadership load
- 16:25Speaker 2: across the cluster over time.
- 16:27Speaker 1: That's excellent to know. Automatic failover is key. So how
- 16:31Speaker 1: do acknowledgements or ACKs play into this? How do producers
- 16:35Speaker 1: know their messages are safely persisted across these replicas before
- 16:38Speaker 1: they move on?
- 16:39Speaker 2: ACKs? Are precisely how producers control the durability guarantee and
- 16:43Speaker 2: ensure messages are safely persisted. There are three main strategies
- 16:47Speaker 2: controlled by the act's producer. Can fig with x zero
- 16:51Speaker 2: it's basically fire and forget send in hope pretty much.
- 16:55Speaker 2: It gives the highest performance because the producer doesn't wait
- 16:58Speaker 2: for any confirmation at all, but it offers the lowest
- 17:01Speaker 2: reliability comforable. Maybe to UDP networking. You could lose messages
- 17:05Speaker 2: if the broker fails immediately.
- 17:07Speaker 1: When would you ever use that?
- 17:08Speaker 2: It's acceptable if some data loss is tolerable, maybe high
- 17:12Speaker 2: volume sensor data where only the latest reading matters and
- 17:15Speaker 2: losing an occasional reading isn't catastrophic, like a temperature sensor
- 17:18Speaker 2: in a non critical system.
- 17:20Speaker 1: Okay, what about AX one. That sounds like a middle ground.
- 17:22Speaker 2: It is AX one means the producer gets a response
- 17:26Speaker 2: and acknowledgment as soon as the leader broker successfully receives
- 17:29Speaker 2: and writes the message to its local log. This offers
- 17:32Speaker 2: much better latency than waiting for all replicas, but data
- 17:34Speaker 2: loss is still possible if the leader receives the message
- 17:38Speaker 2: sends the akaz act back to the producer but then
- 17:41Speaker 2: crashes before that message gets replicated to its followers, that
- 17:44Speaker 2: message is lost.
- 17:45Speaker 1: Ah okay, so it's confirmed by the leader, but not
- 17:49Speaker 1: guaranteed replicated.
- 17:50Speaker 2: Yet exactly, which brings us to AXOL or you can
- 17:53Speaker 2: write as a medico one. This has actually been the
- 17:55Speaker 2: default setting since Kafka three.
- 17:56Speaker 1: Point zero, the safest option.
- 17:58Speaker 2: Yes, AXOL offers the highest reliability with this setting. The
- 18:02Speaker 2: leader waits until all of the current in sync replica's
- 18:05Speaker 2: ISRs have successfully persisted the data to their logs before
- 18:09Speaker 2: sending that final ACK back to the producer.
- 18:11Speaker 1: So you know it's on multiple machines, right.
- 18:14Speaker 2: This is what you definitely want for critical data like
- 18:17Speaker 2: those customer orders, financial transactions, anything you absolutely cannot lose.
- 18:21Speaker 1: So for guaranteed delivery, AXOL is the gold standard. Is
- 18:24Speaker 1: there a way to fine tune exactly how many InSync
- 18:27Speaker 1: replicas need to acknowledge before the leader confirms? Maybe you
- 18:30Speaker 1: don't need all of them, just a majority.
- 18:32Speaker 2: Yes. Absolutely. That's where men dot nsync dot replicas comes in.
- 18:35Speaker 2: It's a topic level configuration setting that works hand in
- 18:38Speaker 2: hand with AXOL.
- 18:39Speaker 1: How does it work?
- 18:40Speaker 2: It specifies the minimum number of ISRs, including the leader
- 18:43Speaker 2: itself that must acknowledge the right before the leader confirms
- 18:47Speaker 2: receipt back to the producer. So if you have a
- 18:49Speaker 2: replication factor of three and you set men dot nsync
- 18:53Speaker 2: dot replicas two, then the right succeeds as long as
- 18:55Speaker 2: the leader and at least one follower confirm it. If
- 18:58Speaker 2: only the leader is available, well, the producer will get
- 19:01Speaker 2: an error and can retry, preventing potential data loss if
- 19:05Speaker 2: too many replicas are temporarily down or slow.
- 19:07Speaker 1: That gives you really fine grain control over the durability
- 19:10Speaker 1: versus availability trade off. Very useful, but what about guaranteeing
- 19:14Speaker 1: messages are written exactly once and in the correct order,
- 19:18Speaker 1: especially if a producer has to retry sending due to
- 19:21Speaker 1: a temporary network issue or something that sounds like a
- 19:23Speaker 1: classic distributed systems headache.
- 19:25Speaker 2: It is a tough problem, but Kaofka has solutions for that.
- 19:29Speaker 2: We turn to idempatance and transactions.
- 19:31Speaker 1: Idempatance, meaning doing something multiple times, has the same effect
- 19:34Speaker 1: as doing.
- 19:35Speaker 2: It once, precisely by setting enabled dot idempatance true on
- 19:39Speaker 2: the producer, which is actually the default now too. Alongside
- 19:42Speaker 2: acts all, Kafka ensures that messages are written in the
- 19:45Speaker 2: correct order. Within a partition and are present exactly once,
- 19:48Speaker 2: even if the producer retries sending.
- 19:50Speaker 1: How does it do that without much overhead?
- 19:53Speaker 2: It uses sequence numbers assigned by the producer and tracked
- 19:55Speaker 2: by the broker. The performance loss is negligible, maybe one
- 19:59Speaker 2: percent or less, but the gain in data integrity is huge.
- 20:03Speaker 2: Imagine if an order place message got duplicated because of
- 20:05Speaker 2: a retry, I defidence prevents that.
- 20:08Speaker 1: Okay, so I dumpetance handles duplicates from producer retries. What
- 20:11Speaker 1: about transactions? When do they come in?
- 20:13Speaker 2: Transactions are for achieving exactly once semantics eos When you're
- 20:18Speaker 2: doing more complex things, especially involving multiple partitions or transferring
- 20:22Speaker 2: data atomically between COFKA and other external systems like databases
- 20:27Speaker 2: or other COFKA topics.
- 20:28Speaker 1: Like a multi step process that needs to succeed or
- 20:31Speaker 1: fail entirely exactly.
- 20:33Speaker 2: A producer can begin a transaction, send messages to multiple partitions,
- 20:37Speaker 2: and then either commit the transaction, making all messages visible
- 20:40Speaker 2: to consumers, or abort it, discarding them all. It's atomic.
- 20:44Speaker 1: How do transactions affect consumers? Do they need to do
- 20:46Speaker 1: anything special?
- 20:47Speaker 2: Yes? Crucially, consumers that need transactional guarantees must set their
- 20:52Speaker 2: isolation dot level configuration to read.
- 20:55Speaker 3: Committed, read committed Okay.
- 20:56Speaker 2: This ensures they only read messages that are part of
- 20:59Speaker 2: successfully committed transactions, filtering out any messages from aborted transactions
- 21:04Speaker 2: or ongoing ones. It's actually good practice to set this
- 21:07Speaker 2: even if you don't use transactions initially, just to be safe.
- 21:10Speaker 1: And how does Kafka manage this atomicity across potentially multiple
- 21:14Speaker 1: brokers and partitions.
- 21:15Speaker 2: It uses a variation of the classic two phase commit protocol. Internally,
- 21:19Speaker 2: it involves transaction coordinators on the brokers and special control messages.
- 21:23Speaker 2: It's complex under the hood, but it provides that strong
- 21:26Speaker 2: guarantee of atonic rights across multiple partitions, ensuring data consistency
- 21:30Speaker 2: throughout your entire data flow.
- 21:32Speaker 1: That's a truly comprehensive approach to reliability from replication and
- 21:36Speaker 1: ACKs right through to idempaitence and transactions. Very impressive. Now,
- 21:41Speaker 1: let's talk about speed. Kafka is famous for its performance.
- 21:45Speaker 1: It's throughput. How does it achieve such high speeds and
- 21:48Speaker 1: what are the key configurations that truly make it fly?
- 21:52Speaker 2: Yeah, performance is definitely one of Kafka's hallmarks. It's inherently
- 21:55Speaker 2: tuned for performance right out of the box. It's design
- 21:58Speaker 2: basically assumes that hard disks are relatively cheap these days
- 22:02Speaker 2: and memory is quite abundant, okay, and it heavily prioritizes
- 22:05Speaker 2: horizontal scaling as we discussed. But to truly make it fly,
- 22:09Speaker 2: optimization through careful configuration settings across all the components producers,
- 22:14Speaker 2: brokers and consumers is vital. It's not just one magic switch.
- 22:17Speaker 1: And you mentioned partitions are key to performance earlier? Can
- 22:21Speaker 1: you elaborate on how they directly contribute to speed and throughput?
- 22:24Speaker 2: Absolutely, partitions are key because they enable massive parallel processing
- 22:28Speaker 2: and load balancing. Remember, topics are divided into partitions and
- 22:31Speaker 2: these partitions are then distributed across the different brokeram machines.
- 22:35Speaker 2: Producers determine which partition to send messages to, usually based
- 22:39Speaker 2: on the key and on the consumer side, we use consumer.
- 22:42Speaker 1: Groups consumer groups. What are those exactly?
- 22:45Speaker 2: A consumer group is just a set of consumer instances
- 22:48Speaker 2: that cooperate to consume from a topic. Kafka automatically assigns
- 22:52Speaker 2: the partitions of a topic across the available consumers in
- 22:56Speaker 2: a group. So if a topic has ten partitions and
- 22:58Speaker 2: you have five consumers in a group. Each consumer will
- 23:01Speaker 2: handle two partitions in parallel.
- 23:03Speaker 1: AH, so the group processes the topic together in parallel
- 23:06Speaker 1: across partitions exactly.
- 23:08Speaker 2: This allows you to scale out your consumption by simply
- 23:11Speaker 2: adding more consumer instances to the group up to the
- 23:15Speaker 2: number of partitions, it drastically increases the overall message processing throughput.
- 23:19Speaker 1: I understand that more partitions can mean more potential parallelism,
- 23:22Speaker 1: more throughput, but it feels like there could be a
- 23:25Speaker 1: point of diminishing returns or even negative consequences. What are
- 23:29Speaker 1: the implications of having too many partitions? Is their downside?
- 23:32Speaker 2: You're absolutely right to be cautious. There definitely is a downside.
- 23:36Speaker 2: While increasing partitions can boost throughput up to a point,
- 23:40Speaker 2: it introduces significant complexity and overhead if you go too far.
- 23:44Speaker 2: Like what well, each partition demand client resources, memory on
- 23:47Speaker 2: producers and consumers on the brokers, Each partition is a
- 23:51Speaker 2: log file on disc requiring file handles, memory for indexing,
- 23:55Speaker 2: and CPU for replication. Thousands or tens of thousands of
- 23:59Speaker 2: partitions can really strain broker resources. It can also lead
- 24:03Speaker 2: to prolonged unavailability during certain failure scenarios like leader elections,
- 24:08Speaker 2: especially with older zookeeper managed clusters, where a zookeeper itself
- 24:12Speaker 2: could become.
- 24:12Speaker 1: A bottleneck, So finding the right number is important crucial.
- 24:15Speaker 2: Imagine our online retailer suddenly deciding to have a million
- 24:18Speaker 2: tiny partitions, one for every single product desk cue. While
- 24:22Speaker 2: it might sound organized for ordering, the overhead of managing
- 24:26Speaker 2: all those partitions, leader, elections, replication traffic, client connections would
- 24:30Speaker 2: likely overwhelm the system and actually reduce overall performance instability.
- 24:33Speaker 1: And can you easily change the number later?
- 24:35Speaker 2: That's another catch. Reducing the number of partitions for a
- 24:39Speaker 2: topic isn't really possible without potentially losing data or complex
- 24:43Speaker 2: manual steps. Increasing partitions is easier. You could do that online,
- 24:47Speaker 2: but increasing partitions disrupts message ordering guarantees for existing keys.
- 24:52Speaker 2: Why because the partitioner usually calculates the target partition using
- 24:56Speaker 2: something like hash key percent number of partitions. If you
- 24:59Speaker 2: chang ange the number of partitions, the result changes and
- 25:02Speaker 2: messages with the same key start going to different partitions
- 25:05Speaker 2: than before, breaking strict ordering for that key until all
- 25:08Speaker 2: the old data expires.
- 25:09Speaker 1: Wow. Okay, so choosing the initial partition count and planning
- 25:13Speaker 1: for future growth is really important. Get it wrong, It's
- 25:16Speaker 1: hard to fix. Easily.
- 25:17Speaker 2: Exactly optimal balance is key usually found through careful testing, monitoring,
- 25:21Speaker 2: and understanding your data access patterns. Don't just pick a
- 25:24Speaker 2: huge number upfront.
- 25:25Speaker 1: That's a very clear warning. So partitions are critical for scaling.
- 25:29Speaker 1: How does the producer specifically contribute to this incredible performance?
- 25:32Speaker 1: Beyond just sending messages?
- 25:34Speaker 2: Producer performance relies heavily on batching. This is super.
- 25:37Speaker 1: Important batching grouping messages.
- 25:40Speaker 2: Yes. Instead of sending each message individually over the network
- 25:44Speaker 2: as soon as it's ready, producers collect messages destined for
- 25:47Speaker 2: the same partition on the same broker and group them
- 25:50Speaker 2: into larger batches than they send the entire batch in
- 25:53Speaker 2: one go.
- 25:53Speaker 1: That must save a lot of network round trips.
- 25:56Speaker 2: Drastically, It significantly enhances performance and reduce uses network load
- 26:01Speaker 2: by sending fewer, larger chunks of data rather than many
- 26:05Speaker 2: small ones.
- 26:05Speaker 1: How do you control that batching?
- 26:07Speaker 2: You can figure it mainly with two settings. Yeah, batch
- 26:10Speaker 2: dot size which sets the maximum batch size and bytes,
- 26:13Speaker 2: and linger dot ms, which is the maximum time in milliseconds.
- 26:17Speaker 2: The producer will wait to try and fill up a
- 26:19Speaker 2: batch before sending it, even if it's not full yet.
- 26:22Speaker 1: So a trade off between latency and throughput exactly.
- 26:25Speaker 2: Larger linger dot m's values like five meters, ten meters
- 26:28Speaker 2: or even more increase latency slightly because messages wait longer,
- 26:32Speaker 2: but they also increase the chance of bigger batches, leading
- 26:34Speaker 2: to much better throughput and efficiency. Finding the sweet spot
- 26:38Speaker 2: depends on your application's latency requirements.
- 26:40Speaker 1: And what about compression? Does that happen at the producer?
- 26:43Speaker 2: Yes, and it's another big performance booster. The producer can
- 26:46Speaker 2: compress the entire batch of messages just once before sending.
- 26:50Speaker 1: It the whole batch, not message by message, whole batch.
- 26:54Speaker 2: This is much more efficient than compressing individual messages. Common
- 26:57Speaker 2: compression types like snappy, gzip, LZ for zstd are supported.
- 27:02Speaker 2: This significantly reduces the amount of data sent over the
- 27:05Speaker 2: network and also saves hard disk space on the brokers
- 27:09Speaker 2: as they store and transmit the compressed batches unchanged.
- 27:12Speaker 1: Clever batching and compression working together. And earlier you mentioned
- 27:16Speaker 1: zero copy transfer as a neat trick for brokers to
- 27:19Speaker 1: achieve high performance. How does that actually make the brokers faster?
- 27:23Speaker 1: What are they doing or rather not doing right?
- 27:25Speaker 2: Broker performance is maximized largely by keeping them as simple
- 27:28Speaker 2: and efficient as possible. Their primary job is in complex computation.
- 27:33Speaker 2: It's really about efficiently pushing bytes from network sockets to
- 27:36Speaker 2: disc when receiving from producers, reducing and pushing bytes from
- 27:40Speaker 2: disc back to network sockets when sending to consumers.
- 27:42Speaker 1: Consuming just moving data pretty much.
- 27:45Speaker 2: And this is where zero copy transfer, a feature available
- 27:48Speaker 2: in Linux and other Unix like operating systems, comes into play.
- 27:52Speaker 2: It's a fundamental reason Kofka can achieve such incredible speeds
- 27:55Speaker 2: on commodity hardware.
- 27:57Speaker 1: So what does zero copy actually avoid?
- 27:59Speaker 2: What cop Imagine the traditional way data moves from the
- 28:03Speaker 2: disc into the operating system kernel's memory page cash, then
- 28:08Speaker 2: copied into the applications memory, the coca broker process, then
- 28:12Speaker 2: copied back into the kernel socket buffer memory, and finally
- 28:15Speaker 2: copied out to the network card. That's multiple copies and memory.
- 28:18Speaker 1: Sounds inefficient, it is.
- 28:20Speaker 2: Zero copy allows the kernel to directly transfer data from
- 28:22Speaker 2: the disc cache page cash straight to the network socket
- 28:25Speaker 2: buffer without needing that intermediate copy into the applications Kafka's
- 28:30Speaker 2: memory space.
- 28:31Speaker 1: It cuts out the middleman the application buffer exactly.
- 28:34Speaker 2: It avoids unnecessary data copies and CPU context switches between
- 28:38Speaker 2: kernel mode and user mode. This makes the broker astonishingly efficient,
- 28:43Speaker 2: acting more like a super fast data pipeline or router
- 28:46Speaker 2: than a heavy processing engine. And because Coffka's message format
- 28:49Speaker 2: on disc is the same as it's over the wire format,
- 28:52Speaker 2: this works beautifully.
- 28:53Speaker 1: That's a really key optimization. And you also mentioned Kofka
- 28:56Speaker 1: often relies on the OS for flushing data to disc
- 28:59Speaker 1: rather than doing it manually after every rite.
- 29:01Speaker 4: Yes.
- 29:02Speaker 2: Generally Kafka avoids forcing manual sink operations after every message
- 29:06Speaker 2: right for performance reasons, and FOLCNC forces the OS to
- 29:09Speaker 2: physically write data from its cashes to the disc hardware immediately,
- 29:13Speaker 2: which it can be slow.
- 29:14Speaker 1: So it risks losing data if the OS crashes before flushing.
- 29:18Speaker 2: In theory, yes, for data that's only in the OS cash,
- 29:21Speaker 2: but Kofka relies on its replication mechanism for durability. By
- 29:25Speaker 2: the time a producer gets an ax AL confirmation, the
- 29:28Speaker 2: data is safely replicated to multiple brokers, OS caches and
- 29:31Speaker 2: likely heading to disk soon via background OS processes. Relying
- 29:35Speaker 2: on replication plus the OS's background flushing provides high throughput
- 29:39Speaker 2: and strong durability guarantees in practice.
- 29:41Speaker 1: Okay, that makes sense. Reliability through replications speed through avoiding
- 29:45Speaker 1: forced sinks, so producers batch and compress brokers use zero copy.
- 29:52Speaker 1: What about the consumer side? Is there a bottleneck there
- 29:55Speaker 1: or is COFKA just pushing data as fast as the
- 29:57Speaker 1: network allows?
- 29:59Speaker 2: Consumer performances is definitely configurable. You have settings like fetch
- 30:02Speaker 2: dot min dot bytes, which tells the broker the minimum
- 30:05Speaker 2: amount of data to send back in one go.
- 30:07Speaker 1: So the consumer isn't getting piny responses all the time.
- 30:11Speaker 2: Right, and fetch dot max dot wheat dot ms the
- 30:14Speaker 2: maximum time the broker will wait for that minimum amount
- 30:16Speaker 2: of data to accumulate before sending back whatever it has.
- 30:19Speaker 2: These help tune the balance between latency and throughput on
- 30:22Speaker 2: the consumer side, similar to the producer's lingered MS.
- 30:25Speaker 1: Okay, but where's the real limit?
- 30:26Speaker 2: Usually here's a crucial insight and something many people overlook
- 30:29Speaker 2: when troubleshooting performance. Consumer performance is typically limited by how
- 30:33Speaker 2: fast the consumer application processes the data, not by COFA itself.
- 30:38Speaker 1: So it's my code that's slow, not COFKA.
- 30:40Speaker 2: Often, yes, COFA brokers are incredibly efficient at serving data.
- 30:45Speaker 2: Our own performance tests and many others often reveal that
- 30:48Speaker 2: consumers can easily pull data much faster than typical producers
- 30:52Speaker 2: can even send it. The bottleneck is frequently your own
- 30:55Speaker 2: application logic. How quickly can your online retailer's inventory serve,
- 31:00Speaker 2: look up product details, updated's database and acknowledge the item
- 31:04Speaker 2: sold event it just received from kofca. Or sometimes it's
- 31:07Speaker 2: simply the network bandwidth available to the consumer, but rarely
- 31:11Speaker 2: is it Kafka's ability to deliver the bytes.
- 31:13Speaker 1: That's a really key distinction to keep in mind for
- 31:15Speaker 1: optimization and troubleshooting. Focus on the consumer application logic first. Okay,
- 31:20Speaker 1: we've covered the core mechanics, reliability, performance, fantastic foundation. Now
- 31:25Speaker 1: let's talk about how coofka integrates with the wider world
- 31:28Speaker 1: of systems and enables that exciting realm of real time
- 31:30Speaker 1: data analysis. How does coofca connect fit into this picture?
- 31:34Speaker 1: What is it?
- 31:35Speaker 2: Coppa connect is a really powerful framework and tool that's
- 31:38Speaker 2: part of the Apache Kofka project. Its purpose is to
- 31:40Speaker 2: make it easy to integrate COFCA with external systems.
- 31:42Speaker 1: External systems like what think.
- 31:44Speaker 2: Databases, key value stores, search indexes, file systems, cloud storage
- 31:50Speaker 2: like S three, messaging queues like JMS, pretty much anything
- 31:54Speaker 2: you'd want to get data at kofka from or get
- 31:57Speaker 2: data out of Kofka into Okay.
- 31:59Speaker 1: So it's like a universe data bridge builder for COFKA.
- 32:02Speaker 2: That's a great way to put it. And crucially, it
- 32:04Speaker 2: aims to do this without you having to write custom
- 32:07Speaker 2: integration code for every single system you use pre built
- 32:10Speaker 2: or community connectors.
- 32:11Speaker 1: So why should you, the listener care about COOFCA connect?
- 32:14Speaker 1: What's the big benefit?
- 32:15Speaker 2: The big benefit is that it helps automate and standardize
- 32:18Speaker 2: data flow to and from Kofka. It massively simplifies building
- 32:22Speaker 2: and managing these data pipelines. For our online retailer example,
- 32:26Speaker 2: it means effortlessly getting customer profile updates from a CRM
- 32:29Speaker 2: system into a COSTA topic or pushing processed order data
- 32:32Speaker 2: from Kofka into a downstream data warehouse or fulfillment system,
- 32:36Speaker 2: all using configuration rather than complex custom code.
- 32:39Speaker 1: Less code, more configuration sounds good. How does it work? Architecturally?
- 32:43Speaker 2: A Kafka connect deployment runs as a cluster of workers.
- 32:47Speaker 2: These are just JVM processes that execute the integration tasks.
- 32:50Speaker 2: They handle skivelling offsets, configuration, and distributing.
- 32:54Speaker 1: The actual work workers running the tasks and the tasks themselves.
- 32:58Speaker 2: The actual integration logic is encapsulated in connectors. These are
- 33:01Speaker 2: plugins that you deploy to your connect pluster. There are
- 33:04Speaker 2: two main types, source connectors and sync connectors.
- 33:06Speaker 1: Source and sync easy enough.
- 33:08Speaker 2: Source connectors import data from an external system into Kofka topics.
- 33:12Speaker 2: For example, a GDBC source connector can pull a database
- 33:16Speaker 2: table for new rows or more powerfully, connectors like Debisium
- 33:20Speaker 2: perform change data capture CDC by reading database transaction logs
- 33:25Speaker 2: and sending every single row level change, insert, update, delete
- 33:29Speaker 2: to Kafka in real time.
- 33:30Speaker 1: CDC is huge for real time data warehousing and replication.
- 33:34Speaker 2: Absolutely and then sync connectors do the opposite. They export
- 33:37Speaker 2: data from Coffka topics to external systems, like writing records
- 33:40Speaker 2: from a Cofka topic into lastic search for searching, or
- 33:43Speaker 2: hdfs for archiving, or maybe calling a rest api.
- 33:46Speaker 1: Very powerful. Can you do any like light transformations on
- 33:50Speaker 1: the messages as they pass through connect maybe clean things
- 33:53Speaker 1: up a bit before they hit kafka or before they
- 33:55Speaker 1: go to the sync system.
- 33:56Speaker 2: Yes, you can. Coffka connects support something called Sync Message
- 34:00Speaker 2: transformations or smts smmt's. These allow you to perform simple,
- 34:05Speaker 2: stateless record level transformations on messages within the connect pipeline.
- 34:09Speaker 2: They could be applied before a message is written to
- 34:11Speaker 2: Kafka by a source connector, or before a message is
- 34:14Speaker 2: written to an external system by a sync.
- 34:16Speaker 1: Connector what kind of transformations.
- 34:18Speaker 2: Common examples include things like renaming fields, replaced field, dropping fields,
- 34:23Speaker 2: replace field again or drop, extracting a field from the
- 34:26Speaker 2: message value to become the message key value, toke, pulling
- 34:30Speaker 2: out a specific field, extract field, or even masking sensitive
- 34:33Speaker 2: fields by setting them to null or a fixed value
- 34:36Speaker 2: mask field for privacy or compliance reasons.
- 34:39Speaker 1: That sounds really useful for basic cleanup or shaping.
- 34:42Speaker 2: It is for light work, but there's an important warning here.
- 34:45Speaker 2: Smts are not a fully fledged ETL extract transform load tool.
- 34:50Speaker 2: They are designed for simple, stateless transformations on individual messages.
- 34:54Speaker 2: If you need complex transformations, stateful operations, joins between different
- 34:59Speaker 2: data sources, or heavy computation, smts are not the right tool.
- 35:04Speaker 1: So for the heavy lifting.
- 35:05Speaker 2: For that you typically turn to a dedicated stream processing framework.
- 35:09Speaker 1: AH stream processing. Perfect segue. Welcome to the world of
- 35:12Speaker 1: stream processing. What exactly is that and why is it
- 35:15Speaker 1: such a natural fit such a big deal When talking
- 35:17Speaker 1: about Kofka.
- 35:18Speaker 2: Stream processing is essentially about processing data continuously as it arrives,
- 35:23Speaker 2: typically in real time or near real time, instead of
- 35:26Speaker 2: collecting data into batches and processing it hours later the
- 35:29Speaker 2: old way. Right, you process potentially unbounded streams of data
- 35:33Speaker 2: events as they flow through the system, like data flowing
- 35:36Speaker 2: through Coofka topics and the benefit This enables instant analysis,
- 35:39Speaker 2: immediate reactions to business changes, and the creation of applications
- 35:43Speaker 2: that are always up to date. Think back to our
- 35:45Speaker 2: online retailer. Instead of knowing total sales only at the
- 35:49Speaker 2: end of the day from a Bash report, stream processing
- 35:53Speaker 2: allows them to see real time sales trends as they happen.
- 35:56Speaker 2: They can detect potentially fraudulent transactions within seconds, or trigger
- 36:01Speaker 2: personalized offers based on a customer's immediate browsing behavior on
- 36:04Speaker 2: their website. It unlocks truly real time capabilities.
- 36:08Speaker 1: That makes sense moving from batch latency to real time responsiveness.
- 36:13Speaker 1: What are some common frameworks people use for this with Kofka.
- 36:16Speaker 2: There are several powerful frame works out there. Kafka streams
- 36:19Speaker 2: is a very popular choice because it's actually a Java
- 36:22Speaker 2: library that's part of the Apache Kofka project itself. It
- 36:25Speaker 2: makes it easy to build stream processing applications that read
- 36:28Speaker 2: from and write to.
- 36:29Speaker 1: Kaofka tightly integrated.
- 36:31Speaker 2: Very then you have other major open source players like
- 36:34Speaker 2: Apache Flank, which is known for its sophisticated state management
- 36:38Speaker 2: and event time processing capabilities. There's also Apache spark streaming,
- 36:42Speaker 2: though it's more microbatch oriented. Historically, and in other ecosystems,
- 36:46Speaker 2: you might see things like Scala's AKA streams or Python's
- 36:49Speaker 2: faust library.
- 36:50Speaker 1: Lots of choices, Let's maybe focus on Kofka streams. Since
- 36:54Speaker 1: it's part of kofka. How do you actually process these
- 36:57Speaker 1: streams using it? What are the building blocks.
- 36:59Speaker 2: And Kafka streams. If you define your processing logic as
- 37:02Speaker 2: a topology of processors, kind of like chaining together operations,
- 37:06Speaker 2: you typically start with a source processor which reads data
- 37:09Speaker 2: from one or more Cofka topics into a stream called
- 37:12Speaker 2: a k stream.
- 37:13Speaker 1: Okay, get the data in then what Then.
- 37:15Speaker 2: You apply various transformation or processing steps. You can filter
- 37:18Speaker 2: messages based on some condition, maybe only keep orders with
- 37:21Speaker 2: the value over one hundred dollars. You can use map
- 37:23Speaker 2: or map values to transform the messages. Map values just
- 37:27Speaker 2: changes the message value. Well, map can change both the
- 37:29Speaker 2: key and the value, or even the type of.
- 37:31Speaker 1: The message useful for reshaping data definitely.
- 37:34Speaker 4: You can merge two different data streams together into one,
- 37:38Speaker 4: or you can split a single stream into multiple downstream
- 37:41Speaker 4: topics based on different conditions, like routing high value orders
- 37:44Speaker 4: to one topic and standard orders.
- 37:46Speaker 1: To another, branching the flow exactly.
- 37:48Speaker 2: And A very common and powerful operation is aggregation. Like count,
- 37:53Speaker 2: This coount's occurrence is per key. For example, continuously counting
- 37:56Speaker 2: how many times each product was viewed or.
- 37:58Speaker 1: Added to a cart. That sounds like it needs to
- 38:01Speaker 1: remember things over time.
- 38:02Speaker 2: It does. Operations like count. Some reduce are stateful. They
- 38:07Speaker 2: need to maintain and update some internal state based on
- 38:10Speaker 2: the incoming messages. Kofka Streams manages this state reliably interesting.
- 38:14Speaker 1: I've also heard of streaming squel being used with Kafka.
- 38:17Speaker 1: Is that like running familiar SQL queries but on live,
- 38:21Speaker 1: constantly changing data streams instead of static tables.
- 38:23Speaker 2: Precisely, streaming SQL offers a higher level declarative way to
- 38:27Speaker 2: define stream processing logic using SQL like syntax. Frameworks like
- 38:31Speaker 2: KSQLDB built on Coofka Streams or flink sql allow you
- 38:35Speaker 2: to write queries like selection productive count from clicks group
- 38:39Speaker 2: by producted directly on data streams.
- 38:41Speaker 1: But what does that query return? A stream doesn't have
- 38:44Speaker 1: an end good point.
- 38:46Speaker 2: Unlike a traditional database query that runs once and returns
- 38:49Speaker 2: a single final result set, a streaming SEQL query typically
- 38:53Speaker 2: runs continuously and produces a new data stream of changes.
- 38:57Speaker 1: A stream of changes.
- 38:58Speaker 2: Yeah, so for that at count query, the output stream
- 39:01Speaker 2: would contain messages indicating the updated count for a productive
- 39:05Speaker 2: Every time the count changes due to a new click
- 39:08Speaker 2: event arriving, it continuously refines the result.
- 39:11Speaker 1: So the result itself is a stream. That's a different
- 39:13Speaker 1: way of thinking it is.
- 39:15Speaker 2: And maybe frameworks like flank sql also support a headless
- 39:18Speaker 2: mode where you can deploy pre defined SQL queries that
- 39:21Speaker 2: just run continuously in the background, perhaps writing their continuously
- 39:24Speaker 2: updated results back to another Kafka topic or an external database.
- 39:28Speaker 1: You mentioned state full operations like counting and how Kaffa
- 39:32Speaker 1: streams manage a state. You also hear about stream states
- 39:35Speaker 1: and tables. How do those fit in? Especially with aggregations.
- 39:38Speaker 2: Right, stream processing frameworks need a way to reliably store
- 39:41Speaker 2: the state required for operations like aggregations, counts, sums, averages,
- 39:46Speaker 2: or for joins between streams in Kaffa streams. This state
- 39:49Speaker 2: is typically stored in local state stores on the machine
- 39:52Speaker 2: running the application instance. These are often backed by embedded
- 39:55Speaker 2: databases like rockstd for performance local storage.
- 39:59Speaker 1: What happens if the the application instance crashes is the state.
- 40:02Speaker 2: Loss ah good question. That's where Kafka's own reliability comes in.
- 40:07Speaker 2: These local state stores are backed by internal change log
- 40:10Speaker 2: topics in Kafka.
- 40:11Speaker 1: Itself changelog topics.
- 40:13Speaker 2: Yes, every update made to the local state store is
- 40:16Speaker 2: also written as a message to a compacted Kofka topic.
- 40:19Speaker 2: If your application instance crashes and restarts, possibly on a
- 40:23Speaker 2: different machine, Kafka streams can automatically restore its local state
- 40:27Speaker 2: by replaying the messages from that changelog topic. It makes
- 40:30Speaker 2: the state fault tolerant.
- 40:31Speaker 1: Clever using Kafka to back up the state of the
- 40:34Speaker 1: stream processor exactly so.
- 40:36Speaker 2: Those aggregations like some or Average, use these state stores
- 40:40Speaker 2: to keep track of the running calculation. The result of
- 40:43Speaker 2: an aggregation in Kafka streams is often represented as a
- 40:46Speaker 2: K table.
- 40:47Speaker 1: A K table. What's that compared to a K stream.
- 40:49Speaker 2: Think of a K stream as representing the raw sequence
- 40:51Speaker 2: of events, the history what happened. A K table, on
- 40:54Speaker 2: the other hand, represents the current state derived from that stream,
- 40:58Speaker 2: like an up to date view or materialize few What
- 41:01Speaker 2: is the current value? So the output of our account
- 41:04Speaker 2: aggregation would be a K table where the key is
- 41:06Speaker 2: the producted and the value is its latest.
- 41:08Speaker 1: Count stream effects table of current state. Got it? And
- 41:12Speaker 1: what about combining data from different streams or enriching a
- 41:16Speaker 1: stream with data from a table. How do streaming joins work?
- 41:19Speaker 1: In this world?
- 41:20Speaker 2: Joins are essential for enriching data. Stream processing frameworks support
- 41:24Speaker 2: various types of joins. You can do stream table joins.
- 41:28Speaker 2: This is common for enrichment. Imagine you have a K
- 41:30Speaker 2: stream of order events and a K table containing customer
- 41:34Speaker 2: profile information keep by customer ID. You can join the
- 41:37Speaker 2: order stream with a customer table to add the customer's
- 41:40Speaker 2: name and address to each order event as it flows through.
- 41:44Speaker 2: The join is typically triggered when a new event arrives
- 41:46Speaker 2: on the stream and it looks up the corresponding key.
- 41:49Speaker 4: In the table.
- 41:50Speaker 1: Okay, enriching events with static ish data. Right.
- 41:54Speaker 2: You can also do table table joints, where changes in
- 41:57Speaker 2: either table can trigger updates to the joined result. This
- 42:00Speaker 2: is useful for combining two evolving data sets. And then
- 42:03Speaker 2: you have stream stream joins joining two potentially infinite streams
- 42:07Speaker 2: of events. This usually requires defining a time window, because
- 42:10Speaker 2: you need to specify how long the system should wait
- 42:12Speaker 2: for a matching event to arrive on the other stream
- 42:15Speaker 2: before giving up. For example, joining AD impressions with AD
- 42:18Speaker 2: clicks based on a user ID within say a five
- 42:21Speaker 2: minute window.
- 42:21Speaker 1: Windows become crucial for stream stream joins. And you mentioned
- 42:26Speaker 1: earlier that for joins to work efficiently, data often needs
- 42:29Speaker 1: to be copartitioned. Can you remind us what that means? Sure?
- 42:33Speaker 2: Copartitioning is a prerequisite for efficient joins and some aggregations
- 42:37Speaker 2: in many distributed stream processing systems, including cough To streams.
- 42:41Speaker 2: It means that records from the different topics being joined,
- 42:44Speaker 2: which share the same joint key, must reside in partitions
- 42:47Speaker 2: with the same ID number across.
- 42:49Speaker 1: Those topics, same key, same partition number, even if in
- 42:52Speaker 1: different topics exactly.
- 42:53Speaker 2: Think of it like this. If you have customer orders
- 42:56Speaker 2: in one Kafka topic orders and customer addresses in another topic,
- 43:00Speaker 2: dresses both potentially partitioned across multiple brokers. For Kafa streams
- 43:04Speaker 2: to efficiently join an order with its corresponding address based
- 43:07Speaker 2: on customer it needs to ensure that the order for
- 43:09Speaker 2: a customer one twenty three Q one twenty three and
- 43:12Speaker 2: the address for customer one twenty three Q one twenty
- 43:14Speaker 2: three both land in say, partition five of their respective topics.
- 43:18Speaker 2: Why is that necessary Because then the Kaffka stream's task
- 43:22Speaker 2: responsible for processing partition five will have local access to
- 43:26Speaker 2: both the order and the address data for customer one
- 43:29Speaker 2: twenty three. It doesn't need to make slow network calls
- 43:32Speaker 2: to fetch data from other partitions or other instances. It
- 43:36Speaker 2: keeps the joint operation efficient and scalable.
- 43:38Speaker 1: It's like ensuring related files are in the same filing
- 43:41Speaker 1: cabinet drawer, even across different cabinets, so you only have
- 43:44Speaker 1: to look in one place.
- 43:45Speaker 2: That's a perfect analogy. If data isn't naturally co partitioned
- 43:49Speaker 2: by key when it arrives, kopfcas streams often needs to
- 43:52Speaker 2: perform an internal repartitioning step, which involves writing the data
- 43:57Speaker 2: to an intermediate correctly partitioned topic before the join can happen.
- 44:01Speaker 2: This adds some overhead, but ensures correctness.
- 44:04Speaker 1: That co partitioning requirement makes perfect sense for distributed joints.
- 44:08Speaker 1: Now time itself seems like a really crucial and potentially
- 44:11Speaker 1: tricky concept in stream processing. You mentioned event time earlier.
- 44:15Speaker 1: What are the different time concepts we need to be
- 44:17Speaker 1: aware of and why does it matter which one you use?
- 44:20Speaker 2: Yes, Understanding time is absolutely vital and choosing the wrong
- 44:23Speaker 2: time semantic can lead to inaccurate results. There are generally
- 44:28Speaker 2: four key time concepts people talk about. First, event time.
- 44:33Speaker 2: This is when the event actually occurred in the real world,
- 44:35Speaker 2: like the timestamp generated by the sensor when it took
- 44:38Speaker 2: a reading, or the exact moment a customer clicked a
- 44:40Speaker 2: button on the website.
- 44:42Speaker 1: The time it happened.
- 44:43Speaker 2: Second, create time. This is the time when the producer
- 44:46Speaker 2: application created the COFCA message. This is often close to
- 44:50Speaker 2: event time, but could be later if there's a delay
- 44:53Speaker 2: in the producing system. This is actually the default time
- 44:56Speaker 2: stamp stored in COFCA messages if the producer doesn't explicitly
- 44:59Speaker 2: sell one. Third, log a pen time this is the
- 45:03Speaker 2: time when the coffer broker received the message and appended
- 45:06Speaker 2: it to the partition's log. This timestamp is assigned by
- 45:09Speaker 2: the broker itself. Messages within a partition are strictly ordered
- 45:12Speaker 2: by log.
- 45:12Speaker 1: A pen time Okay, broker received time.
- 45:15Speaker 2: And finally, stream time or sometimes called processing time. This
- 45:19Speaker 2: is the time when the message is actually processed by
- 45:21Speaker 2: the stream processing application.
- 45:23Speaker 1: Instance.
- 45:24Speaker 2: This is usually the latest of all the time stamps
- 45:26Speaker 2: and can be affected by processing delays, network latency, etc.
- 45:30Speaker 1: So event time create time log a pen time, stream
- 45:33Speaker 1: processing time. Why does the choice matter so much?
- 45:36Speaker 2: It matters because if you want accurate results that reflect
- 45:40Speaker 2: the real world sequence of events, especially when dealing with
- 45:43Speaker 2: data that might arrive late or out of order, which
- 45:45Speaker 2: is common in distributed systems, you generally want to use
- 45:47Speaker 2: event time.
- 45:48Speaker 1: Even if messages arrive out of sequence.
- 45:51Speaker 2: Yes, processing based on event time allows the system to
- 45:54Speaker 2: correctly handle out of order data and produce results consistent
- 45:58Speaker 2: with when things actually happened. Example, if you're calculating hourly
- 46:01Speaker 2: sales totals, using event time ensures a sale that occurred
- 46:05Speaker 2: at ten five h zero five am but arrive late
- 46:07Speaker 2: at eleven five zero five am still gets counted in
- 46:10Speaker 2: the ten point zero zero eleven point zero am window.
- 46:13Speaker 2: Using processing time would put it in the wrong hour.
- 46:16Speaker 1: Ah. That makes a huge difference for accuracy. But processing
- 46:19Speaker 1: based on event time sounds more complex.
- 46:21Speaker 2: It is more complex. The stream processor needs mechanisms to
- 46:25Speaker 2: handle potentially late arriving data, often using concepts like water
- 46:28Speaker 2: marks to track the progress of event time and decide
- 46:32Speaker 2: when it's safe to finalize calculations for a given time.
- 46:34Speaker 2: Window processing time is simpler, but less accurate for many
- 46:37Speaker 2: use cases.
- 46:38Speaker 1: Okay, that clarifies the time concepts and building on that
- 46:41Speaker 1: you mentioned, time windows are often used with stream processing,
- 46:44Speaker 1: especially for aggregations or joints. What are some common types
- 46:47Speaker 1: of windows and one would you use them? Come?
- 46:49Speaker 2: Windows are fundamental for defining boundaries for calculations on unbanded streams.
- 46:54Speaker 2: Common types include tumbling windows. These are fixed size, non
- 46:57Speaker 2: overlapping windows. Think of them like slicing time into consecutive chunks,
- 47:01Speaker 2: for example, calculating total sales for each distinct hour ten
- 47:04Speaker 2: point zero zero, eleven point zero zero, eleven point zero zero, zero, twelve,
- 47:08Speaker 2: de verits, et cetera. Great for curiotic.
- 47:10Speaker 1: Reports fixed separate blocks. Got it?
- 47:12Speaker 2: Then you have sliding windows. These also have a fixed length,
- 47:16Speaker 2: but they slide forward continuously by a specified slide interval,
- 47:20Speaker 2: meaning the windows overlap. For example, calculating the average website
- 47:24Speaker 2: response time over the last five minutes updated every one minute.
- 47:27Speaker 2: Useful for monitoring moving averages or recent trends.
- 47:30Speaker 1: Overlapping continuously updated.
- 47:32Speaker 2: Few right, they're also hopping windows. These are similar to
- 47:36Speaker 2: sliding windows fixed length overlapping, but defined by both the
- 47:39Speaker 2: window size and a fixed advancement interval the hop For example,
- 47:43Speaker 2: calculating a daily report covering the last seven days where
- 47:46Speaker 2: the window is seven days long and it hops forward
- 47:49Speaker 2: by one day each day.
- 47:50Speaker 1: Okay, like a sliding window, but maybe advancing less frequently
- 47:53Speaker 1: kind of.
- 47:54Speaker 2: And finally, session windows these are quite different. Their boundaries
- 47:57Speaker 2: aren't based on fixed time intervals, but on peer of
- 48:00Speaker 2: inactivity in the data stream.
- 48:02Speaker 1: Grouped by key inactivity. How does that work?
- 48:04Speaker 2: You define a session gap duration for a given key
- 48:08Speaker 2: like a user ID. All events arriving within that gap
- 48:11Speaker 2: duration of each other are grouped into the same session window.
- 48:15Speaker 2: If no event arrives for that key for longer than
- 48:17Speaker 2: the gap, the session is considered closed and the next
- 48:20Speaker 2: event starts a new session. Perfect for tracking user sessions
- 48:24Speaker 2: on a website where session ends after say thirty minutes
- 48:27Speaker 2: of no clicks from that user.
- 48:29Speaker 1: That's really clever for activity based analysis. Lots of windowing options,
- 48:33Speaker 1: so we have all these powerful stream processing capabilities with
- 48:36Speaker 1: Kafka streams transformations, state management, joins Windows. How does Kafka
- 48:41Speaker 1: streams actually achieve parallelization for all this work? If I
- 48:45Speaker 1: run multiple instances of my streaming application, how do they coordinate?
- 48:48Speaker 2: Kaffka Streams leverages Costca's own partitioning model for parallelization, which
- 48:53Speaker 2: is really elegant. It effectively splits the processing topology your
- 48:56Speaker 2: chain of K streams and K tables into independent units
- 49:00Speaker 2: called tasks. Each task is responsible for processing data from
- 49:04Speaker 2: one or more specific partitions of the input Cofka topics.
- 49:07Speaker 1: So one task per input partition roughly generally.
- 49:10Speaker 2: Yes, although a task might process partitions from multiple topics
- 49:14Speaker 2: if they're part of a join or merge. These tasks
- 49:17Speaker 2: are the smallest unit of parallelization. Kaffka Streams then automatically
- 49:22Speaker 2: distributes these tasks as evenly as possible across all the
- 49:25Speaker 2: running instances of your application that share the same application
- 49:28Speaker 2: dot eight ah.
- 49:29Speaker 1: The application dot A links the instances together.
- 49:32Speaker 2: Correct It acts like the consumer group i D we
- 49:34Speaker 2: discussed earlier. If you have say, ten partitions in your
- 49:39Speaker 2: input topic, and you run five instances of your Coffa
- 49:41Speaker 2: streams application with the same id Kaffa streams will assign
- 49:45Speaker 2: two tasks and thus two partitions to each instance to
- 49:49Speaker 2: process in parallel.
- 49:50Speaker 1: And what happens if one of those application instances fails Coffa.
- 49:54Speaker 2: Streams handles that automatically too, using Kafka's underlying consumer group
- 49:58Speaker 2: rebalancing protocol. If an instance fails or leaves the group,
- 50:01Speaker 2: its task are automatically redistributed among the remaining healthy instances. Similarly,
- 50:06Speaker 2: if you add a new instance, tasks will be migrated
- 50:08Speaker 2: to it to rebalance the load. This provides elasticity and
- 50:11Speaker 2: fault tolerance for your stream processing very resilient.
- 50:14Speaker 1: You mentioned repartitioning earlier for joins, Does that involve these
- 50:17Speaker 1: tasks too?
- 50:18Speaker 2: Yes. For operations like key based joins or aggregations group
- 50:22Speaker 2: by key count, et cetera that require data to be
- 50:25Speaker 2: grouped by key, Kofka streams might need to perform that
- 50:28Speaker 2: repartitioning step we talked about. This is done internally by
- 50:31Speaker 2: writing the relevant data stream to a special intermediate KOFCA
- 50:35Speaker 2: topic often called a repartition topic, which is correctly partitioned
- 50:39Speaker 2: by the required key. Then downstream tasks read from this
- 50:42Speaker 2: repartition topic. This effectively shuffles the data across the tasks
- 50:46Speaker 2: based on the key, ensuring all messages for a specific
- 50:49Speaker 2: key are processed by the same task, even if they
- 50:51Speaker 2: originally came from different input partitions. This might split your
- 50:55Speaker 2: overall processing logic into what COFFCA Streams calls sub topologies
- 50:59Speaker 2: connected by these interns ernal repartition topics, optimizing dataflow and correctness.
- 51:03Speaker 1: That's incredibly powerful and quite sophisticated under the hood, allowing
- 51:07Speaker 1: complex stateful processing to scale out and be fault tolerant.
- 51:11Speaker 1: But with all this power comes responsibility. Right, we've built
- 51:14Speaker 1: this amazing real time data nervous system. Let's talk about
- 51:19Speaker 1: management and security. How do you keep KOFKA healthy, compliant,
- 51:23Speaker 1: and secure, especially in a large production environment with many
- 51:27Speaker 1: teams using it.
- 51:28Speaker 2: You're absolutely right. Once KOFKA becomes central to your data architecture,
- 51:32Speaker 2: effective governance becomes crucial. Without it, things can quickly descend
- 51:35Speaker 2: into chaos.
- 51:36Speaker 1: Chaos how well.
- 51:38Speaker 2: Imagine different teams producing data to the same topic but
- 51:41Speaker 2: using slightly different formats or field names. Without agreement. Downstream
- 51:44Speaker 2: consumer's break data becomes inconsistent, trust or roads. You risk
- 51:49Speaker 2: that garbage in garbage out scenario.
- 51:50Speaker 1: We mentioned so defining clear rules is step one.
- 51:53Speaker 2: Yes, even if you don't use a formal tool initially,
- 51:57Speaker 2: data always has a schema, implicit or explicit. Documenting and
- 52:03Speaker 2: agreeing on schemas between producers and consumers is paramount For
- 52:06Speaker 2: our online retailer. The team producing order events needs to
- 52:10Speaker 2: agree with the teams consuming them, fulfillment analytics, etc. On
- 52:14Speaker 2: exactly what fields are present, their types, and whether they
- 52:17Speaker 2: are required or optional.
- 52:19Speaker 1: Okay, agree on the schema, But schemas evolve. What about
- 52:23Speaker 1: handling changes? How do you ensure a change made by
- 52:25Speaker 1: one team doesn't break everyone else.
- 52:27Speaker 2: That's where schema compatibility levels come into play. These are
- 52:30Speaker 2: rules that define how schemas are allowed to evolve over time.
- 52:33Speaker 2: They cover in changes like adding or deleting fields or
- 52:36Speaker 2: changing types.
- 52:37Speaker 1: What are the common levels?
- 52:38Speaker 2: You typically have no compatibility or no nell anything goes.
- 52:42Speaker 2: Any change is allowed, even breaking ones like renaming a
- 52:45Speaker 2: required field very risky. Backward compatibility new schemas must be
- 52:50Speaker 2: readable by applications using older schemas. This usually means you
- 52:53Speaker 2: can add optional fields or delete existing fields, but not
- 52:56Speaker 2: add required fields or rename existing ones. Consumers run older
- 53:00Speaker 2: code won't break when encountering new data.
- 53:02Speaker 1: Okay, new consumers can read old data. Wait, no other
- 53:05Speaker 1: way around. Old consumers can read new data. Let me rephrase.
- 53:09Speaker 1: Backward means consumers using the new schema can still process
- 53:13Speaker 1: data written with the old schema. You can add optional
- 53:16Speaker 1: fields or delete fields. Ah.
- 53:18Speaker 2: Yes, let me clarify that. Backward compatibility means consumers using
- 53:22Speaker 2: the new schema can process data produced with the old schema.
- 53:25Speaker 2: This usually allows deleting fields or making required fields optional.
- 53:29Speaker 1: Got it, new code reads old data.
- 53:32Speaker 2: Then forward compatibility, consumers using an old schema can process
- 53:36Speaker 2: data produced with the new schema. This usually allows adding
- 53:39Speaker 2: new fields typically optional, or making optional fields required. Old
- 53:43Speaker 2: code won't break when seeing new data.
- 53:45Speaker 1: Formats old code reads new data.
- 53:47Speaker 2: And finally, full compatibility. This combines both backward and forward
- 53:52Speaker 2: Both new and old consumers can read both new and
- 53:54Speaker 2: old data. This is the safest but often the most restrictive,
- 53:58Speaker 2: typically only allowing adding or moving optional fields.
- 54:01Speaker 1: Choosing the right compatibility level seems critical for managing change smoothly.
- 54:05Speaker 2: Absolutely, it prevents unexpected breakages as your data landscape evolves.
- 54:09Speaker 1: And that leads us naturally to schema registries. I assume
- 54:12Speaker 1: are these the tools that enforce these compatibility rules exactly.
- 54:16Speaker 2: Schema registries like the popular Confluence Schema Registry or alternatives
- 54:21Speaker 2: like care Paths or EPICUREA registry act as a central
- 54:23Speaker 2: authority or single source of truth for all schemas used
- 54:26Speaker 2: within your Kafka ecosystem.
- 54:28Speaker 1: What do they do?
- 54:29Speaker 2: They store schemas like Avro, Poto, Boof or Jason schema definitions,
- 54:35Speaker 2: manage different versions of those schemas, and critically, they enforce
- 54:39Speaker 2: the compatibility rules you've defined for each topic or subject.
- 54:43Speaker 2: In registry terms, when a producer tries to send data,
- 54:47Speaker 2: it often first checks with the registry if the schema
- 54:49Speaker 2: it's using is compatible with the registered versions for that
- 54:52Speaker 2: topic according to the configured compatibility level. If not, the
- 54:55Speaker 2: registry can reject the attempt, preventing incompatible data from ever
- 54:59Speaker 2: entering cope. Consumers also use a registry to fetch the
- 55:02Speaker 2: correct schema to de serialize incoming data.
- 55:05Speaker 1: So the registry acts like a gatekeeper for schema quality
- 55:07Speaker 1: and evolution.
- 55:08Speaker 2: Precisely, it's a cornerstone of good Kafka governance.
- 55:11Speaker 1: Okay governance handles the data structure. Moving to security, what
- 55:16Speaker 1: are the core concerns for protecting your Kafka cluster and
- 55:18Speaker 1: the data flowing through it from unauthorized access or potential breaches.
- 55:22Speaker 1: This must be top of mind for anyone running Cofka
- 55:25Speaker 1: with sensitive data.
- 55:26Speaker 2: Security is absolutely paramount, and it involves several layers. First,
- 55:29Speaker 2: you need authentication. This verifies who a client, producer, consumer, broker,
- 55:34Speaker 2: dual claims to be. Common mechanisms include using mutual TLS MTLs,
- 55:40Speaker 2: where both the client and server present certificates to verify
- 55:43Speaker 2: each other's identity.
- 55:45Speaker 1: Encrypted and authenticated connection.
- 55:47Speaker 2: Right, or using SSL simple authentication and security layer which
- 55:51Speaker 2: supports various pluggable methods like Curbaro's common and traditional enterprises
- 55:55Speaker 2: plane user name password used with TLS scram, more secure challenges,
- 56:00Speaker 2: sponsor passwords or even o opatonide connect via SaaS loft
- 56:03Speaker 2: bearer for integration with modern identity providers.
- 56:05Speaker 1: So confirm identity first.
- 56:08Speaker 2: Then what Once a client is authenticated? You need authorization.
- 56:11Speaker 2: This defines what an authenticated client is actually allowed to do.
- 56:14Speaker 2: Can it read from topic A? Can it write to
- 56:16Speaker 2: topic B? Can it create new topics?
- 56:18Speaker 1: Controlling permissions exactly?
- 56:20Speaker 2: Kafka typically handles this via Access control Lists ACLS. You
- 56:24Speaker 2: define rules specifying which user principle has which permission read, write, create, describe, etc.
- 56:30Speaker 2: On which resource, topic, group cluster. The best practice here
- 56:35Speaker 2: is always the least privileged principle. Grant only the permissions
- 56:38Speaker 2: absolutely necessary for a client to perform its function, nothing more.
- 56:42Speaker 1: Don't give the marketing analytics consumer rate access to the
- 56:46Speaker 1: payment processing topic.
- 56:47Speaker 2: Definitely not. ACLS prevent that.
- 56:49Speaker 1: Okay, Authentication and authorization control access. What about protecting the
- 56:53Speaker 1: data itself, both as it moves across the network and
- 56:56Speaker 1: when it's sitting on the broker's discs.
- 56:58Speaker 2: Good point. That involves encryption for data in transit between
- 57:01Speaker 2: clients and brokers or between brokers themselves. You use transport encryption,
- 57:05Speaker 2: typically TLS Transport Layer Security, the successor to SSL. Enabling.
- 57:10Speaker 2: TLS encrypts all the COOFKA traffic, preventing eavesdropping on the network.
- 57:13Speaker 1: Is there a performance hit?
- 57:14Speaker 2: Yes, TLS does introduce some CPU overhead for the encryption
- 57:18Speaker 2: decryption process, so there's a performance cost, but it's often
- 57:22Speaker 2: a necessary cost for security. KOFKA cleverly supports configuring multiple
- 57:26Speaker 2: listeners per broker, For example, one plaintext listener on port
- 57:29Speaker 2: nine zero nine two and one TLS listener on part
- 57:31Speaker 2: nine zero nine three. This allows for gradual migration of
- 57:34Speaker 2: clients to TLS without downtime.
- 57:36Speaker 1: Okay TLS for data in motion. What about encryption at
- 57:40Speaker 1: rest when data is stored on the broker discs.
- 57:42Speaker 2: Kofka itself doesn't provide built in features for encrypting data
- 57:45Speaker 2: stored within its log files on disc. For encryption at rest,
- 57:49Speaker 2: you typically rely on capabilities of the underlying operating system
- 57:52Speaker 2: or storage system, for instance, using filesystem level encryption like
- 57:56Speaker 2: Linux's dmcrypt LUKS or features provided by cloud storage volumes
- 58:01Speaker 2: like ebs encryption on AWS.
- 58:03Speaker 1: So handle it at the infrastructure.
- 58:05Speaker 2: Layer generally yes. Alternatively, a pattern sometimes used as employing
- 58:09Speaker 2: a secure KOFCA proxy that encrypts message values before they
- 58:12Speaker 2: are even produced to Kafka and decrypts them after consumption.
- 58:15Speaker 2: This has complexity, but ensures the data on the broker
- 58:17Speaker 2: disc is encrypted at the application level.
- 58:19Speaker 1: And what about true end to end encryption where only
- 58:23Speaker 1: the original producer and final consumer can decrypt the message
- 58:27Speaker 1: and even the brokers can't see the plaintext.
- 58:30Speaker 2: That offers the highest level of confidentiality for critical data. However,
- 58:34Speaker 2: it must be implemented entirely by the client applications themselves.
- 58:38Speaker 2: The producer incrudes the message value before sending, and the
- 58:41Speaker 2: consumer decrypts it after receiving. KOFKA just transports the encrypted
- 58:46Speaker 2: byt RAY. There's no widely adopted standard library or built
- 58:50Speaker 2: in KOFKA feature for this, so it requires careful implementation
- 58:53Speaker 2: and key management on the client side.
- 58:55Speaker 1: Okay, so multiple layers often off c TLS encryption and
- 58:59Speaker 1: transit infrastructure encryption at rest, an optional client side end
- 59:03Speaker 1: to end encryption seems comprehensive. What if you have an
- 59:07Speaker 1: existing cluster that was set up without security enabled. Is
- 59:10Speaker 1: it a massive disruptive project to secure it later without
- 59:13Speaker 1: causing significant downtime?
- 59:15Speaker 2: Fortunately, no, it's usually manageable. You can secure an unsecured
- 59:18Speaker 2: cluster gradually without affecting availabilities significantly. The key is using
- 59:22Speaker 2: those multiple listeners. You can add new secure listeners example
- 59:26Speaker 2: saslpls alongside the existing plaintex listeners on all brokers, usually
- 59:31Speaker 2: requiring rolling restarts of the brokers one by one. Then
- 59:35Speaker 2: you update the inner broker communication protocol to use the
- 59:38Speaker 2: secure listener another rolling restart. Finally, you migrate your client
- 59:42Speaker 2: applications incrementally to connect to the secure listeners and configure
- 59:45Speaker 2: their authentication credentials. Once all clients are migrated, you can
- 59:49Speaker 2: optionally disable the old plaintex listeners, a well defined process
- 59:53Speaker 2: designed to minimize disruption, so.
- 59:55Speaker 1: It's not an all or nothing, big bang cutover. That's
- 59:58Speaker 1: very reassuring for organizations looking to improve their security posture. Now,
- 1:00:02Speaker 1: what about managing resource usage? We talked about performance, but
- 1:00:05Speaker 1: how do you prevent a single misbehaving or poorly coded
- 1:00:08Speaker 1: application from consuming excessive resources and potentially impacting the entire
- 1:00:13Speaker 1: cluster and all other users.
- 1:00:14Speaker 2: That's where resource allocations, specifically quotas come into play.
- 1:00:18Speaker 1: Quotas limits.
- 1:00:19Speaker 2: Yes, Kafka allows administrators to set quotas on resource consumption
- 1:00:24Speaker 2: for clients. Their primary purpose is really to protect the
- 1:00:27Speaker 2: cluster from excessive load caused by misconfigured, buggy, or even
- 1:00:31Speaker 2: malicious clients. It's generally not intended as a mechanism to
- 1:00:35Speaker 2: artificially limit well behaved clients or enforced strict service tiers,
- 1:00:39Speaker 2: though some use it that way.
- 1:00:40Speaker 1: What kind of resources can you limit?
- 1:00:42Speaker 2: The main quota is control produce and consume throughput rates
- 1:00:46Speaker 2: measured invites per second. You can set a producer bitter
- 1:00:48Speaker 2: quota and a consumer bitter quota. There's also a request
- 1:00:51Speaker 2: percentage quota that limits the percentage of CPU time a
- 1:00:54Speaker 2: client's request can utilize on the broker's network and IO threads,
- 1:00:57Speaker 2: preventing CPU starvation.
- 1:01:00Speaker 1: Bandwidth and CPU usage limits. Can you set these limits
- 1:01:03Speaker 1: broadly or target specific users or applications.
- 1:01:06Speaker 2: You can define quotas at different levels. You can set
- 1:01:08Speaker 2: them based on the client dot ID property configured in
- 1:01:11Speaker 2: the producer or consumer application. However, client dot ID can
- 1:01:16Speaker 2: sometimes be easily spoofed or shared across instances. A more
- 1:01:20Speaker 2: robust approach is to set quotas at the authenticated user level,
- 1:01:24Speaker 2: based on the principle derived from SASEL or TLS. Authentication.
- 1:01:28Speaker 2: User level quotas are generally considered more reliable for enforcement.
- 1:01:32Speaker 2: You can also set default quotas per user or per
- 1:01:35Speaker 2: client ID.
- 1:01:36Speaker 1: What's the best practice for setting these quota values? Should
- 1:01:39Speaker 1: you be really strict.
- 1:01:40Speaker 2: The general best practice is actually to set quotas quite generously,
- 1:01:44Speaker 2: well above the normal expected peak usage for a client,
- 1:01:47Speaker 2: monitor the actual usage closely. The idea is to use
- 1:01:50Speaker 2: quotas as a safety net or a safeguard to catch
- 1:01:52Speaker 2: runaway clients or denial of service attempts, rather than using
- 1:01:56Speaker 2: them as a strict bottleneck that clients regularly bump up
- 1:01:58Speaker 2: against during normal operation. They're like circuit breakers, not fine grain.
- 1:02:02Speaker 1: Traffic shapers use them as guardrails, not speed limits for
- 1:02:05Speaker 1: everyday traffic. Makes sense. We've talked a lot about Kofka's internals,
- 1:02:09Speaker 1: capabilities management, What about actually running it? What are the
- 1:02:13Speaker 1: common deployment models? How do people typically deploy and operate
- 1:02:17Speaker 1: KOFCA clusters in the real world.
- 1:02:19Speaker 2: You have several options, each with its own set of
- 1:02:21Speaker 2: trade offs regarding control, cost and operational effort. The traditional
- 1:02:26Speaker 2: approach is running Kafka on your own hardware in your
- 1:02:28Speaker 2: own data centers. This gives you maximum control over the
- 1:02:31Speaker 2: environment hardware selection and configuration, but it also requires the
- 1:02:35Speaker 2: most significant operational expertise for planning, provisioning, automation, monitoring, patching, upgrades.
- 1:02:42Speaker 1: Everything, high control, high responsibility exactly.
- 1:02:46Speaker 2: A very common variation is running Kafka in virtualized environments
- 1:02:50Speaker 2: like VMware OpenStack on top of your own hardware or
- 1:02:53Speaker 2: private cloud infrastructure. This adds a layer of virtualization management,
- 1:02:57Speaker 2: but follows similar principles. Key considerations here are distributing brokers,
- 1:03:02Speaker 2: evenly across physical VM hosts to avoid single points of failure,
- 1:03:06Speaker 2: and carefully considering storage performance, preferring local SSDs over shared
- 1:03:11Speaker 2: network attached storage SANDS and NASS if latency and throughput
- 1:03:15Speaker 2: are critical, as network storage can sometimes introduce unpredictable performance.
- 1:03:19Speaker 1: Okay, self managed on prem or private cloud? What about
- 1:03:22Speaker 1: public cloud? Kumernetes seems popular these days?
- 1:03:25Speaker 4: Right?
- 1:03:25Speaker 2: Running Kafka on Kubernetes has become increasingly popular, especially for
- 1:03:29Speaker 2: organizations that already have strong operational teams comfortable with managing
- 1:03:32Speaker 2: stateful workloads on k ads.
- 1:03:34Speaker 1: Isn't running something stateful like Cofka on Kubernetes tricky?
- 1:03:37Speaker 2: It can be. Managing storage, networking and upgrades requires care. However,
- 1:03:43Speaker 2: the ecosystem has matured significantly. The community standard for this
- 1:03:47Speaker 2: is generally considered to be Strimsy Strimsey dot io. It's
- 1:03:50Speaker 2: a Kubernetes operator specifically designed for deploying and managing Kofka
- 1:03:54Speaker 2: clusters along with components like Coffca, Connect, mirror, Maaker, etc.
- 1:03:58Speaker 2: On Kubernetes automate. It's many complex operational tasks like provisioning,
- 1:04:03Speaker 2: configuration management, rolling upgrade certificate management, making it much more manageable,
- 1:04:08Speaker 2: but it still requires a solid understanding of both Cofka
- 1:04:10Speaker 2: and Kubernetes.
- 1:04:12Speaker 1: So Strimsey helps bridge the gap for Kubernetes users. What
- 1:04:15Speaker 1: about just using a fully managed service.
- 1:04:18Speaker 2: That's the other major direction, using public cloud managed services
- 1:04:22Speaker 2: platforms like conflent cloud from the original creators of Kafka,
- 1:04:25Speaker 2: Amazon MSK Managed Streaming for Kafka, Avan for Apache Kofka
- 1:04:30Speaker 2: as your HD on sidez Kafka, Google Cloud pub sub.
- 1:04:33Speaker 2: Though different, sometimes used as alternative, they have stracked away most,
- 1:04:36Speaker 2: if not all, of the underlying infrastructure.
- 1:04:38Speaker 1: Management sounds appealing. What's the catch?
- 1:04:40Speaker 2: The appeal is obvious, faster deployment, reduced operational burden, built
- 1:04:45Speaker 2: in scalability and reliability features. The catch, or rather the
- 1:04:49Speaker 2: trade offs, are typically reduced control over the fine grain configuration, potential,
- 1:04:54Speaker 2: vendor lock in, and cost which can sometimes be higher
- 1:04:57Speaker 2: than self managing a very large scale. Even with a
- 1:05:01Speaker 2: managed service, you still need significant in house Kofka expertise.
- 1:05:05Speaker 2: You need to understand Kofka concepts to design your applications correctly,
- 1:05:08Speaker 2: choose the right service tier, understand the service's limitations like
- 1:05:12Speaker 2: maximum retention periods, throughput cabs, partition limits, troubleshoot application level issues,
- 1:05:18Speaker 2: and manage costs effectively. It's not no OPS, it's different OPS.
- 1:05:22Speaker 1: Managed service simplifies infrastructure, but not application design or KOFCA knowledge.
- 1:05:27Speaker 1: Good point. Finally, regardless of how you deploy it, keeping
- 1:05:30Speaker 1: an eye on everything once it's running seems essential. Monitoring
- 1:05:33Speaker 1: and alerting must be crucial for a distributed system like
- 1:05:36Speaker 1: Kafka that's likely underpinning critical applications absolutely crucial.
- 1:05:40Speaker 2: While Kofka is designed to be robust and fault tolerant,
- 1:05:43Speaker 2: it's not invulnerable. Things can still go wrong. Brokers can
- 1:05:47Speaker 2: run out of disk space, networks can become saturated, consumers
- 1:05:51Speaker 2: can fall behind, partitions can become under replicated.
- 1:05:54Speaker 1: Why is monitoring so important? What are you trying to achieve?
- 1:05:58Speaker 2: The primary goals of monitoring are to detect problems quickly,
- 1:06:01Speaker 2: ideally before they cause a major outage or data loss,
- 1:06:04Speaker 2: and provide insights needed for troubleshooting and capacity planning. You
- 1:06:09Speaker 2: want to prevent a small issue on one broker from
- 1:06:11Speaker 2: cascading into a complete cluster failure.
- 1:06:14Speaker 1: What are some of the absolute key metrics you should
- 1:06:16Speaker 1: be watching the critical vital signs?
- 1:06:18Speaker 2: There are many metrics available via JMX, but some key
- 1:06:21Speaker 2: ones include Under replicated partitions, this metric, exposed by the
- 1:06:26Speaker 2: controller broker, counts the number of partitions that currently don't
- 1:06:29Speaker 2: have their full set of InSync replicas. This value should
- 1:06:32Speaker 2: ideally always be zero. If it's greater than zero for
- 1:06:35Speaker 2: a sustained period, it indicates a problem with replication and
- 1:06:38Speaker 2: reduced fault tolerance. That's a top priority alert.
- 1:06:41Speaker 1: Underreplicated equals bad got it.
- 1:06:43Speaker 2: Active controller count should be exactly one across the entire cluster.
- 1:06:48Speaker 2: If it's zero or one, the clusters in a bad state,
- 1:06:51Speaker 2: offline petitions count, similar to underreplicated discounts. Partitions whose leader
- 1:06:56Speaker 2: is offline should also be zero. Broker level metrics like
- 1:07:00Speaker 2: leader count and partition count, These should be relatively balanced
- 1:07:02Speaker 2: across all brokers in the cluster. If one broker has
- 1:07:05Speaker 2: vastly more leaders or partitions than others, it indicates a
- 1:07:08Speaker 2: load imbalance. Replication lag metrics like max lag under Kafka
- 1:07:12Speaker 2: dot server replica fectro managers show the maximum lag between
- 1:07:15Speaker 2: a leader and its followers. High lag means followers are
- 1:07:18Speaker 2: falling behind, increasing risks during failover.
- 1:07:20Speaker 1: Lag is important for consumers too write definitely.
- 1:07:24Speaker 2: Consumer lag, often calculated externally by monitoring tools by comparing
- 1:07:28Speaker 2: the consumer group's committed offset with the latest offset in
- 1:07:31Speaker 2: the partition, is critical. It shows how far behind a
- 1:07:33Speaker 2: consumer group is in processing messages. High or constantly increasing
- 1:07:37Speaker 2: lag indicates the consumers can't keep up. Also, watch basic
- 1:07:41Speaker 2: throughput bites in PERSEC bites OP per SC messages in
- 1:07:44Speaker 2: per sec at the broker and topic level to understand
- 1:07:46Speaker 2: load and detect anomalies. Network and request metrics request Q
- 1:07:51Speaker 2: size should be near zero. Request latent zemes P ninety
- 1:07:54Speaker 2: nine or P nine ninety nine are useful to spot
- 1:07:56Speaker 2: processing bottlenecks and for consumer groups COFFA, dot com consumer
- 1:08:00Speaker 2: dot consumer coordinator. Metrics related to rebalances, repellance, latency, max, rebalanced, total,
- 1:08:05Speaker 2: frequent or long rebalances can indicate instability in the consumer group, example,
- 1:08:10Speaker 2: consumers crashing repeatedly.
- 1:08:11Speaker 1: That's a good list of critical signals. Yeah, so, how
- 1:08:13Speaker 1: do you approach alerting based on these metrics without getting
- 1:08:15Speaker 1: drowned in constant notifications, especially in dynamic environments.
- 1:08:19Speaker 2: That's the art of good alerting. First, not every metric
- 1:08:22Speaker 2: needs an alert. Focus on metrics that indicate a real
- 1:08:25Speaker 2: actionable problem impacting service health or data integrity, like under
- 1:08:29Speaker 2: replicated partitions. High consumer lag beyond a threshold brokers being down. Second,
- 1:08:35Speaker 2: set meaningful thresholds based on your baseline performance and SLOs.
- 1:08:39Speaker 2: Don't alert if consumer lag spikes for one minute during
- 1:08:42Speaker 2: a brief load burst if it recovers quickly, alert if
- 1:08:45Speaker 2: it stays high for ten minutes. Third, allows systems time
- 1:08:48Speaker 2: for self healing where appropriate. If you're running on Kubernetes,
- 1:08:52Speaker 2: maybe don't page the on call engineer immediately. If for
- 1:08:54Speaker 2: broker pod crashes, Kubernetes might restart it successfully within a minute.
- 1:08:58Speaker 2: Alert only if the problem persists, be on the expected
- 1:09:00Speaker 2: auto recovery time.
- 1:09:02Speaker 1: Build in some tolerance for self heal right.
- 1:09:05Speaker 2: And finally, always enrich your alerts with context. An alert
- 1:09:08Speaker 2: message should clearly state what is wrong, where, which cluster,
- 1:09:12Speaker 2: which topic, group, the severity, and ideally provide links to
- 1:09:16Speaker 2: relevant dashboards for investigation or even point to specific troubleshooting
- 1:09:20Speaker 2: steps or alert playbooks. An alert for our online retailer
- 1:09:23Speaker 2: that just says metric excess high is useless. An alert
- 1:09:27Speaker 2: saying critical order processing consumer group lag one million messages
- 1:09:31Speaker 2: for fifteen men's on broad COSTCA cluster dashboard, dot link playbook.
- 1:09:34Speaker 2: Dot link is much more effective.
- 1:09:36Speaker 1: Context makes alerts actionable, not just noise. Excellent advice. We've
- 1:09:40Speaker 1: covered a huge amount of ground how Kofka works, how
- 1:09:43Speaker 1: it performs, how it integrates, how it's managed and secured.
- 1:09:45Speaker 1: Truly a deep dive. But as with any complex distributed system,
- 1:09:49Speaker 1: things can still go wrong on a larger scale. Let's
- 1:09:51Speaker 1: talk disaster management. How do you prepare for the really
- 1:09:53Speaker 1: bad scenarios like an entire data center going offline unexpectedly.
- 1:09:57Speaker 2: Disaster management is absolutely critical for business continuity, especially when
- 1:10:02Speaker 2: Kafka is underpinning core operations. Kaffa's own architecture provides some
- 1:10:06Speaker 2: inherent resilience here. Its asyncreitous nature, for example, helps mitigate
- 1:10:11Speaker 2: temporary network partitions or brief compute failures. If a producer
- 1:10:15Speaker 2: can't reach the broker, it can often buffer messages and
- 1:10:18Speaker 2: retry later. If a consumer gets disconnected, it can usually
- 1:10:22Speaker 2: reconnect and resume from where it left off using its
- 1:10:24Speaker 2: committed offsets. Data isn't typically lost just because of transient
- 1:10:28Speaker 2: connectivity issues.
- 1:10:30Speaker 1: Okay, it handles temporary glitches, Well, what about more permanent
- 1:10:33Speaker 1: compute failures like a single broker machine dying completely within
- 1:10:37Speaker 1: a cluster.
- 1:10:37Speaker 2: As we discuss with reliability, Kafka is explicitly designed to
- 1:10:41Speaker 2: handle individual compute failures gracefully. Assuming you've configured adequate replication
- 1:10:46Speaker 2: with a replication factor of say three and min dot
- 1:10:49Speaker 2: insnc dot replica set to two, the cluster can tolerate
- 1:10:52Speaker 2: the loss of one broker per partition without any loss
- 1:10:55Speaker 2: of data availability for rights all of yours or reads.
- 1:10:58Speaker 1: Automatic leader fail over kicks in exactly.
- 1:11:01Speaker 2: The cluster heals itself by electing new leaders from the
- 1:11:04Speaker 2: remaining in sync replicas. This is a core part of
- 1:11:07Speaker 2: Kofka's high availability promise within a single cluster deployment.
- 1:11:11Speaker 1: That's good for failures within a deployment, but what about
- 1:11:14Speaker 1: the really big one, a full data center failure. If
- 1:11:17Speaker 1: your entire Kofka cluster is in one DC and that
- 1:11:20Speaker 1: DC goes dark power, loss, network outage, natural disaster, you're offline,
- 1:11:25Speaker 1: right you are?
- 1:11:26Speaker 2: If the entire cluster lives in that single DC, that's
- 1:11:29Speaker 2: a major risk for critical applications. So for true disaster
- 1:11:33Speaker 2: recovery across data centers, you need more sophisticated strategies which
- 1:11:37Speaker 2: significantly increase complexity and cost.
- 1:11:39Speaker 1: What are the main approaches.
- 1:11:40Speaker 2: One approach is to build a stretched cluster.
- 1:11:43Speaker 1: Stretched.
- 1:11:43Speaker 2: Yes, you deploy single logical Kofka cluster, but the brokers
- 1:11:46Speaker 2: are physically distributed across multiple data centers or availability zones ASS.
- 1:11:51Speaker 2: For example, you might place brokers in three different ass
- 1:11:54Speaker 2: within the same geographic region.
- 1:11:55Speaker 1: So it operates as one cluster, just geographically spread out.
- 1:11:59Speaker 2: Correct. The coordination mechanism craft or zookeeper also needs to
- 1:12:03Speaker 2: be stretched across these locations. If one entire data center
- 1:12:07Speaker 2: AZ fails, the Kafka cluster can potentially remain operational as
- 1:12:11Speaker 2: long as a majority of coordinators remain online and partitions
- 1:12:14Speaker 2: still have a live leader in one of the surviving
- 1:12:16Speaker 2: locations and enough ISRs meet the men dot InSync dot
- 1:12:20Speaker 2: replicas requirement.
- 1:12:21Speaker 1: What are the downsides of stretching?
- 1:12:23Speaker 2: The main downside is latency. Network latency between data centers
- 1:12:27Speaker 2: is typically much higher than within a single DC. This
- 1:12:30Speaker 2: increased latency impacts produced request times, especially for AXOL replication
- 1:12:35Speaker 2: lag and failover times. It generally requires dcs that are
- 1:12:39Speaker 2: relatively close geographically with low latency, high bandwidth links between them,
- 1:12:43Speaker 2: and you typically need at least three locations dcs or
- 1:12:46Speaker 2: azs to reliably maintain a quorum for the coordination cluster
- 1:12:49Speaker 2: if one location fails.
- 1:12:51Speaker 1: So stretched clusters offer high availability, become with latency trade offs,
- 1:12:54Speaker 1: and require careful network planning. What's the alternative if stretching
- 1:12:58Speaker 1: isn't feasible?
- 1:12:59Speaker 2: The other common approach is using multiple independent Kofka clusters
- 1:13:03Speaker 2: and replicating data between them using tools like Kofka's own
- 1:13:06Speaker 2: mirror Maker, specifically mirror Maker two, which is built on
- 1:13:10Speaker 2: the Connect framework.
- 1:13:11Speaker 1: Mirroring copying data between clusters exactly.
- 1:13:15Speaker 2: You continuously copy messages from topics in one cluster to
- 1:13:18Speaker 2: topics in another cluster, usually located in a different data
- 1:13:21Speaker 2: center or region. You can set various topologies with mirroring,
- 1:13:25Speaker 2: like what a common one is? Active passive. You have
- 1:13:28Speaker 2: your primary active cluster in one DC where producers send
- 1:13:32Speaker 2: data and consumers normally read from mirror Maker then copies
- 1:13:36Speaker 2: this data to a passive cluster in a separate dr
- 1:13:40Speaker 2: disaster recovery data center.
- 1:13:41Speaker 1: What's the passive cluster used for?
- 1:13:43Speaker 2: It serves as a hot standby. If the active cluster fails,
- 1:13:46Speaker 2: you would need to manually or via automation fail over
- 1:13:50Speaker 2: your producers and consumers to start using the passive cluster instead.
- 1:13:54Speaker 2: This setup is also often used for data migration between
- 1:13:57Speaker 2: clusters or for centralizing data for analysis. Each regional clusters
- 1:14:00Speaker 2: mirroring data to a main headquarters.
- 1:14:02Speaker 1: Cluster, so failover is typically a manual step in active passive.
- 1:14:06Speaker 1: What about active active does that avoid manual failover?
- 1:14:09Speaker 2: An active active setup involves having two or more independent clusters,
- 1:14:13Speaker 2: both actively serving producer and consumer traffic and configured to
- 1:14:17Speaker 2: mirror data to each other. For example, users in Europe
- 1:14:21Speaker 2: connect to the EU cluster, uses in the US connect
- 1:14:24Speaker 2: to the US cluster, and mirror Maker copies data in
- 1:14:26Speaker 2: both directions between them.
- 1:14:28Speaker 1: That sounds complex to manage, especially avoiding infinite loops of
- 1:14:31Speaker 1: mirroring the same message back and forth.
- 1:14:33Speaker 2: It is complex. Mirror Maker two handles the looping issue
- 1:14:36Speaker 2: by automatically prefixing mirrored topics with the name of the
- 1:14:40Speaker 2: source cluster. For example, data from topic A in the
- 1:14:43Speaker 2: USE cluster arrives in the UTH cluster as USE cluster
- 1:14:47Speaker 2: dot Topic A. This prevents it from being mirrored back again.
- 1:14:51Speaker 2: The bigger challenge with active active is often on the
- 1:14:53Speaker 2: application side. You need to ensure your consumer services can
- 1:14:56Speaker 2: handle potentially processing the same logical event twice, once from
- 1:15:00Speaker 2: the local cluster, once mirrored from the remote cluster, or
- 1:15:03Speaker 2: implement logic to de duplicate or process only based on origin.
- 1:15:08Speaker 2: Our online retailer would need very careful application designed to avoid, say,
- 1:15:11Speaker 2: double charging a customer shipping an order twice. If using
- 1:15:14Speaker 2: active active, it provides higher availability and potentially lower latency
- 1:15:18Speaker 2: for users connecting to their local cluster, but demands more
- 1:15:21Speaker 2: sophisticated application logic.
- 1:15:22Speaker 1: Active Active sounds powerful, but requires careful thought about idempotency
- 1:15:26Speaker 1: or deduplication and consumers any other mirroring topologies.
- 1:15:30Speaker 2: Another useful one is hub and spoke. This is great
- 1:15:33Speaker 2: for distributed organizations. Imagine a central hub Kafka cluster at
- 1:15:37Speaker 2: headquarters and multiple smaller spoke clusters at regional offices, factories,
- 1:15:43Speaker 2: or even retail stores like.
- 1:15:44Speaker 1: Our supermarket chain example.
- 1:15:46Speaker 2: Exactly, espoke cluster might handle local operations and then mirror
- 1:15:50Speaker 2: relevant data like sales summaries up to the central hub
- 1:15:53Speaker 2: for company wide aggregation and analysis. The hub might also
- 1:15:57Speaker 2: mirror down commands or configuration updates to the spokes. This
- 1:16:00Speaker 2: allows spokes to operate somewhat independently. Even if connectivity to
- 1:16:03Speaker 2: the hub is intermittent, and then sync up later. Think
- 1:16:06Speaker 2: cruise ships needing to operate autonomously at sea and then
- 1:16:09Speaker 2: sink data when they reach port.
- 1:16:10Speaker 1: Hub and spoke seems well suited for those kinds of
- 1:16:13Speaker 1: distributed environments. So stretched clusters or mirroring with various patterns
- 1:16:18Speaker 1: offer ways to handle large scale disasters. Kafka is clearly
- 1:16:22Speaker 1: incredibly versatile, powerful and resilient when used correctly. But just
- 1:16:26Speaker 1: as important as knowing when and how to use it
- 1:16:29Speaker 1: is knowing when not to use Kaofka. It's not a
- 1:16:31Speaker 1: silver bullet for every data problem, is it. What are
- 1:16:34Speaker 1: some crucial limitations or scenarios where kofka might be the
- 1:16:37Speaker 1: wrong tool for the job.
- 1:16:39Speaker 2: That's a vital point to cover. Kaffa is amazing, but
- 1:16:42Speaker 2: applying it inappropriately leads to frustration and poor results. There
- 1:16:45Speaker 2: are several key anti patterns. First, and perhaps most importantly,
- 1:16:49Speaker 2: Kaffa is not a relational database.
- 1:16:51Speaker 1: We touched on this with the log versus state idea.
- 1:16:54Speaker 2: Right Coffee excels at storing the history of events what happened,
- 1:16:58Speaker 2: It's generally poor at representing and querying the current state
- 1:17:01Speaker 2: of complex entities, especially if that requires complex joints across
- 1:17:05Speaker 2: multiple normalized tables or point lookups based on arbitrary criteria
- 1:17:10Speaker 2: like finding a user by email address when the topic
- 1:17:12Speaker 2: is key by user ID. Don't try to replace your
- 1:17:15Speaker 2: operational databases postgress, MySQL, et cetera with Kofka for storing
- 1:17:20Speaker 2: the canonical queriable state of your application entities. Use databases
- 1:17:24Speaker 2: for that. Messages flowing through Kafka should ideally be denormalized,
- 1:17:28Speaker 2: meaning a single message contains all the relevant information needed
- 1:17:31Speaker 2: for that event, potentially duplicating data found elsewhere, rather than
- 1:17:35Speaker 2: requiring complex lookups for joins later, use relational databases for
- 1:17:39Speaker 2: your service's internal data persistence and complex querying needs.
- 1:17:42Speaker 1: So you wouldn't use kofcas, CASEQL or streams API to
- 1:17:46Speaker 1: directly serve a request like find customer excess current shipping address.
- 1:17:49Speaker 1: If that address might have changed many times, You'd query
- 1:17:52Speaker 1: a proper database that stores the current address exactly.
- 1:17:56Speaker 2: You might build that database view using data stream from Kofka.
- 1:17:59Speaker 2: But Kafka itself isn't the primary query engine for current
- 1:18:02Speaker 2: state lookups in that way.
- 1:18:03Speaker 1: Okay, not a database replacement. What else is it not?
- 1:18:06Speaker 2: Second Kafka is not a synchronous communication interface or a
- 1:18:10Speaker 2: request response system, meaning avoid using KOFKA for interactions where
- 1:18:14Speaker 2: a client sends a request and needs an immediate blocking
- 1:18:17Speaker 2: response back on the same connection. Think of a web
- 1:18:20Speaker 2: browser calling a back end API to fetch user profile
- 1:18:23Speaker 2: data that needs a quick HTTP response. Kofka is designed
- 1:18:26Speaker 2: for asynchronous data exchange. Producers send messages and typically don't
- 1:18:30Speaker 2: wait for or even know about the consumers. Consumers process
- 1:18:34Speaker 2: messages at their own pace. Trying to force synchronous request
- 1:18:37Speaker 2: response patterns over Kafka e g. Producer sends topic A,
- 1:18:40Speaker 2: waits for a consumerative process, and send a apply to
- 1:18:43Speaker 2: topic B. Producer reads from topic B is usually complex, brittle,
- 1:18:46Speaker 2: and inefficient compared to using standard RPC, rest APIs or
- 1:18:49Speaker 2: gRPC for synchronous needs.
- 1:18:51Speaker 1: So if your online stores checkout page needs that instant
- 1:18:54Speaker 1: payment accepted or payment declined feedback to show the user,
- 1:18:58Speaker 1: you'd use a direct API call to the payment service,
- 1:19:02Speaker 1: not send a command via Kafka and hope for a
- 1:19:04Speaker 1: quick reply message.
- 1:19:05Speaker 2: Precisely use the right tool for the job. KOFKA for
- 1:19:08Speaker 2: asynchronous event streams APIs for synchronous interactions.
- 1:19:12Speaker 1: Makes sense and what about sending large files? You mentioned
- 1:19:15Speaker 1: the one mebe default limit earlier right.
- 1:19:17Speaker 2: Third, KOFKA is not a file exchange platform. It is
- 1:19:21Speaker 2: highly optimized for processing a large volume of relatively small messages,
- 1:19:25Speaker 2: typically under that ONEVAB default and often much smaller kilobytes.
- 1:19:29Speaker 2: These messages are usually structured machine readable data like JSON
- 1:19:33Speaker 2: or AVRO. Trying to send large binary files like multi
- 1:19:36Speaker 2: megabyte PDFs, high resolution images, video files directly inside KOFCA
- 1:19:41Speaker 2: message values is generally a very bad idea. Why specifically
- 1:19:44Speaker 2: it performs poorly It consumes excessive broker disk space, puts
- 1:19:48Speaker 2: heavy load on network bandwidth, increases memory pressure on clients
- 1:19:52Speaker 2: and brokers, and can lead to processing timeouts and instability.
- 1:19:55Speaker 2: Kofka's internal mechanisms aren't designed for efficiently handling huge blobs.
- 1:19:59Speaker 1: Like that, So what's the alternative? If you need to
- 1:20:02Speaker 1: signal that a large file is ready for processing, The.
- 1:20:05Speaker 2: Standard pattern is to store the large file in a
- 1:20:07Speaker 2: dedicated object storage system like AWSS three, Google Cloud Storage,
- 1:20:12Speaker 2: or an internal file server, and then send a small
- 1:20:15Speaker 2: COFFCA message containing metadata about the file, including a reference
- 1:20:18Speaker 2: or pointer like the S three URL to its location.
- 1:20:22Speaker 2: The consumer reads the small notification message from COFCA and
- 1:20:25Speaker 2: then uses the reference to fetch the large file directly
- 1:20:28Speaker 2: from the storage system for processing. Keep large payloads out
- 1:20:31Speaker 2: of cofka itself.
- 1:20:33Speaker 1: Use COFCA for the notification, not the file transfer. Got it.
- 1:20:36Speaker 1: Does it always make sense to implement coofka even for
- 1:20:38Speaker 1: smaller projects or simpler data needs. Is there a complexity threshold?
- 1:20:43Speaker 2: That's a good question. Fourth coofka is used for small
- 1:20:46Speaker 2: applications can sometimes be questionable. While kafka brings immense power
- 1:20:50Speaker 2: and scalability, it also introduces operational complexity. Setting up, managing, monitoring,
- 1:20:55Speaker 2: securing and upgrading a COFFCA cluster, even a small one,
- 1:20:59Speaker 2: or even using managed service, which still requires configuration and understanding,
- 1:21:03Speaker 2: involves overhead. For very small scale applications or simple point
- 1:21:07Speaker 2: to point integration needs, the complexity of introducing kofka might
- 1:21:10Speaker 2: outweigh its benefits. Sometimes a simpler solution, like using a
- 1:21:14Speaker 2: message queue built into your application framework, relying on database triggers,
- 1:21:18Speaker 2: or polling using a lightweight cloud queue service, or even
- 1:21:21Speaker 2: just direct API calls might be perfectly sufficient and much
- 1:21:25Speaker 2: easier to manage. Don't introduce kafka just because it's popular,
- 1:21:28Speaker 2: make sure the problem warrants its capabilities. Don't bring a
- 1:21:31Speaker 2: bazooka to a knife fight, so to speak.
- 1:21:34Speaker 1: Evaluate the trade offs, don't over engineer makes sense. And finally,
- 1:21:39Speaker 1: the source material has this great warning which you alluded
- 1:21:41Speaker 1: to earlier. If garbage is produced into Kofka, garbage will
- 1:21:45Speaker 1: also come out at the consumer side. What does that
- 1:21:47Speaker 1: truly mean in practice and why is it such an
- 1:21:49Speaker 1: important closing thought?
- 1:21:50Speaker 2: It means that ultimately Kafka is not a substitute for
- 1:21:54Speaker 2: good architecture and good data practices upstream. Kaffa itself provides
- 1:21:58Speaker 2: incredible freedom and flex dixability and how you produce and
- 1:22:01Speaker 2: consume data. It faithfully and reliably transports the bite arrays
- 1:22:05Speaker 2: you give it, but it doesn't inherently understand or validate
- 1:22:09Speaker 2: the semantic meaning or business correctness of that data beyond
- 1:22:12Speaker 2: basic scheme of validation. If you use a schema registry, it.
- 1:22:15Speaker 3: Just moves the bytes exactly.
- 1:22:17Speaker 2: So, if the data quality being produced into Kafka is poor,
- 1:22:20Speaker 2: if producers send malform messages, inconsistent values, incorrect calculations, or
- 1:22:25Speaker 2: just plain wrong information, Kafka will diligently deliver that poor
- 1:22:29Speaker 2: data to all interested consumers. The consumers will then either
- 1:22:33Speaker 2: crash trying to process the garbage, make bad decisions based
- 1:22:36Speaker 2: on the garbage, or have to implement complex, defensive logic
- 1:22:39Speaker 2: to try and clean up the garbage. This highlights the
- 1:22:42Speaker 2: Kafka's power, lized not just in the technology itself, but
- 1:22:45Speaker 2: crucially in the thoughtful architecture, the data modeling, the schema governance,
- 1:22:49Speaker 2: the validation logic and producers, and the overall data quality
- 1:22:52Speaker 2: strategy you build around it. Coffa is a powerful tool,
- 1:22:56Speaker 2: but its effectiveness depends entirely on how well you design
- 1:22:59Speaker 2: and manage the entire gata ecosystem it enables. You won't
- 1:23:02Speaker 2: magically fix up stream data problems.
- 1:23:03Speaker 1: Garbage in, garbage out, faithfully delivered at scale. A very
- 1:23:07Speaker 1: sobering and important reminder while you have just completed a
- 1:23:11Speaker 1: very deep dive into apatche Kofka. We went from its
- 1:23:13Speaker 1: fundamental components, messages, topics, partitions, brokers, and its unique nature
- 1:23:19Speaker 1: as a.
- 1:23:19Speaker 2: Distributed log all the way through to replication acknowledgments, idempotence
- 1:23:24Speaker 2: for reliability, and.
- 1:23:25Speaker 1: How it achieves incredible performance through batching, compressions, zero copy
- 1:23:29Speaker 1: and parallel processing. With partitions.
- 1:23:32Speaker 2: We explored its power for integrating systems using KOFCA connect
- 1:23:35Speaker 2: and SMTS, and dove into the world of real time
- 1:23:38Speaker 2: stream processing with Kofka streams, covering state tables, joins, and
- 1:23:42Speaker 2: time concepts.
- 1:23:43Speaker 1: And we didn't forget management and security, governance schema registries, authentication, authorization,
- 1:23:50Speaker 1: encryption quotas, deployment models, and crucial monitoring and alerting.
- 1:23:54Speaker 2: Plus how to handle disasters using stretched clusters or mirroring
- 1:23:58Speaker 2: patterns like active passes in Hubbin.
- 1:24:00Speaker 1: Spoke and critically, we also covered the scenarios where Kaffka
- 1:24:04Speaker 1: might not be the best fit, ensuring you have that
- 1:24:06Speaker 1: balanced and practical understanding.
- 1:24:08Speaker 2: It's been quite a journey through the Kafka ecosystem.
- 1:24:11Speaker 1: Indeed, the key takeaway for you listening is hopefully clear.
- 1:24:15Speaker 1: Kofka isn't just another messaging system off the shelf. It's
- 1:24:18Speaker 1: a truly foundational technology that, when you strategically and thoughtfully,
- 1:24:23Speaker 1: can genuinely transform how your organization handles data, enabling that
- 1:24:27Speaker 1: shift towards real time operations and insights.
- 1:24:30Speaker 2: That transformation potential is real.
- 1:24:32Speaker 1: But as we've seen, Kafka empowers you with incredible flexibility,
- 1:24:37Speaker 1: and this brings us back to that final crucial point.
- 1:24:40Speaker 1: Remember this, Kaffka doesn't care about the messages it transports.
- 1:24:43Speaker 1: It's agnostic. If garbage is produced into Kafka, garbage will
- 1:24:47Speaker 1: also come out of the consumer side.
- 1:24:49Speaker 2: It faithfully delivers what it's given exactly.
- 1:24:52Speaker 1: It's true power lies not just in the impressive technology itself,
- 1:24:55Speaker 1: but in the thoughtful architecture, the rigorous data quality practices,
- 1:24:59Speaker 1: and the careful you bring to it.
- 1:25:01Speaker 2: It really underscores the importance of that end to end
- 1:25:03Speaker 2: thinking about your data pipelines.
- 1:25:05Speaker 1: So as you reflect on your own data challenges and opportunities,
- 1:25:09Speaker 1: what stands out to you from today's deep dive. What
- 1:25:11Speaker 1: aspects of Kofka's architecture, its capabilities, or even its limitations
- 1:25:15Speaker 1: might you explore further for your own needs or projects.
- 1:25:18Speaker 1: Keep asking those questions, keep digging deeper, because in the
- 1:25:21Speaker 1: world of data, the learning never truly stops