repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

opencode/skills/presenterm/references/example-kafka.md

Raw

title: "Streaming Data with Kafka" sub_title: A quick introduction author: Viktor Gamov theme: name: catppuccin-mocha override: footer: style: template right: "{current_slide} / {total_slides}" height: 2

Why Streaming?

Every business is becoming a real-time business.

Batch processing means hours of delay. Event streaming means milliseconds.

Let's see how Apache Kafka makes this possible.

What is Kafka?

Architecture

%%{init: {'theme': 'dark'}}%%
flowchart LR
    subgraph Producers
        P1[App 1]
        P2[App 2]
    end
    subgraph Kafka["Kafka Cluster"]
        B1[(Broker 1)]
        B2[(Broker 2)]
        B3[(Broker 3)]
        B1 <--> B2
        B2 <--> B3
    end
    subgraph Consumers
        C1[Analytics]
        C2[Search Index]
    end
    P1 --> B1
    P2 --> B2
    B1 --> C1
    B3 --> C2

Demo Time

Producer Code

import org.apache.kafka.clients.producer.*;

Properties props = new Properties();
props.put("bootstrap.servers", "localhost:9092");

Producer<String, String> producer =
    new KafkaProducer<>(props);

producer.send(new ProducerRecord<>(
    "my-topic", "key", "value"
));

producer.close();

Data Model

direction: right

topics: Topics {
    shape: sql_table
    id: int {constraint: primary_key}
    name: varchar
    partitions: int
}

messages: Messages {
    shape: sql_table
    id: bigint {constraint: primary_key}
    topic_id: int {constraint: foreign_key}
    key: bytea
    value: bytea
}

topics.id <-> messages.topic_id

Summary

Kafka enables real-time data streaming at scale.

Thank you!

Questions?

Markdown source
File outline
---
title: "**Streaming** Data with _Kafka_"
sub_title: A quick introduction
author: Viktor Gamov
theme:
  name: catppuccin-mocha
  override:
    footer:
      style: template
      right: "{current_slide} / {total_slides}"
      height: 2
---

<!-- speaker_note: THE BIG WHY - establish motivation immediately -->

# Why Streaming?

Every business is becoming a real-time business.

<!-- pause -->

Batch processing means **hours of delay**. Event streaming means
**milliseconds**.

<!-- pause -->

Let's see how Apache Kafka makes this possible.

<!-- end_slide -->

# What is Kafka?

<!-- incremental_lists: true -->

- **Producers** send events to topics
- **Consumers** read events from topics
- **Brokers** store and replicate the data
- Events are **immutable** and **ordered** within a partition

<!-- end_slide -->

# Architecture

```mermaid +render
%%{init: {'theme': 'dark'}}%%
flowchart LR
    subgraph Producers
        P1[App 1]
        P2[App 2]
    end
    subgraph Kafka["Kafka Cluster"]
        B1[(Broker 1)]
        B2[(Broker 2)]
        B3[(Broker 3)]
        B1 <--> B2
        B2 <--> B3
    end
    subgraph Consumers
        C1[Analytics]
        C2[Search Index]
    end
    P1 --> B1
    P2 --> B2
    B1 --> C1
    B3 --> C2
```

<!-- end_slide -->

<!-- jump_to_middle -->

# Demo Time

<!-- speaker_note: Cave Painting - scripted demo steps below -->

<!-- end_slide -->

# Producer Code

```java {1-3|5-8|10-13|all}
import org.apache.kafka.clients.producer.*;

Properties props = new Properties();
props.put("bootstrap.servers", "localhost:9092");

Producer<String, String> producer =
    new KafkaProducer<>(props);

producer.send(new ProducerRecord<>(
    "my-topic", "key", "value"
));

producer.close();
```

<!-- speaker_note: Traveling Highlights - walk through each block -->

<!-- end_slide -->

# Data Model

```d2 +render
direction: right

topics: Topics {
    shape: sql_table
    id: int {constraint: primary_key}
    name: varchar
    partitions: int
}

messages: Messages {
    shape: sql_table
    id: bigint {constraint: primary_key}
    topic_id: int {constraint: foreign_key}
    key: bytea
    value: bytea
}

topics.id <-> messages.topic_id
```

<!-- end_slide -->

# Summary

<!-- alignment: center -->

Kafka enables real-time data streaming at scale.

**Thank you!**

Questions?