Logo Backend Data Streaming

Backend Data Streaming

Cộng đồng
j4flmao
backend-data-streaming

Use this skill when the user says 'data streaming', 'kafka architecture', 'stream processing', 'flink job', 'kafka streams', 'exactly once', 'watermarks', 'windowed aggregation', 'consumer lag', 'log compaction'. Designs backend streaming pipelines on Kafka (or compatible logs) with Flink or Kafka Streams: partitioning, consumer groups, offset/commit strategy, stateful processing, event time and watermarks, and exactly-once configuration. Do NOT use for: simple pub/sub between services (backend-event-driven-architecture), broker selection for task queues (backend-message-queue), analytics warehouse/lakehouse pipelines (data-streaming in skills/data).

Tổng quan

Nhà phát hànhj4flmao
Kho mãagent-skills
Tên kỹ năngbackend-data-streaming
Sao
41
Bản fork
6
Tệp đi kèm
7
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI là Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 7 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được j4flmao công bố trên GitHub. Hãy đọc nội dung nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Backend Data Streaming trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL thư mục kỹ năng bên dưới và xác nhận.
    https://github.com/j4flmao/agent-skills/tree/main/skills/backend/universal/data-streaming
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/j4flmao/agent-skills.git /tmp/agent-skills
mkdir -p .claude/skills
cp -r /tmp/agent-skills/skills/backend/universal/data-streaming .claude/skills/backend-data-streaming
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Backend Data Streaming trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự tải Backend Data Streaming ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên Backend Data Streaming không bị giới hạn ở mô hình mà kỹ năng này được viết cho. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên kỹ năng chưa dùng không tốn chi phí.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Data Streaming Architecture

Purpose

Build pipelines that process continuous event streams with predictable latency and correct results under failures, late data and redelivery. Covers Kafka topic design, consumer scaling, processing semantics, and stateful stream processing with Flink or Kafka Streams.

Agent Protocol

Trigger

Exact user phrases: "data streaming", "kafka architecture", "stream processing", "flink job", "kafka streams", "exactly once", "watermarks", "windowed aggregation", "consumer lag", "log compaction".

Input Context

  • Event sources, volume (events/s, bytes/s), and latency target.
  • Ordering and correctness needs (approximate OK vs exact counts, money).
  • Processing engine in use or allowed (Flink, Kafka Streams, Spark Structured Streaming, plain consumers).
  • Sinks (DB, search index, another topic, warehouse).

Output Artifact

Pipeline diagram, topic/partition plan, producer/consumer/processor config, and processing code. No files unless requested.

Response Format

Pipeline: {source} -> {topic(partitions, RF)} -> {processor} -> {sink}
Key: {partition key}   Ordering: per key
Semantics: {at-least-once + idempotent sink | exactly-once (transactions)}
Time: {event time, watermark = max_ts - {lateness}} Window: {tumbling/sliding/session, size}
State: {store/backend, TTL}   Checkpoint: {interval}

Kafka Fundamentals That Drive Design

ConceptRule
PartitionUnit of ordering and parallelism. Order is only guaranteed within a partition
KeySame key -> same partition (default hash partitioner), so key by the entity whose order matters
Consumer groupEach partition is consumed by at most one member of a group; members beyond the partition count sit idle
Partition countCan be increased but not decreased; increasing remaps keys, breaking per-key order for in-flight data. Size for future peak
RetentionTime/size-based delete, or cleanup.policy=compact to keep the latest value per key (changelogs, state rebuild). Tombstone = null value deletes a key
Replicationreplication.factor=3 with min.insync.replicas=2 and producer acks=all survives one broker loss without data loss
MetadataKafka 4.x runs only in KRaft mode; ZooKeeper is gone

Offset Commit Strategy

StrategyConfigResult
Auto commitenable.auto.commit=true (periodic, auto.commit.interval.ms)Commits on a timer regardless of processing: crash can lose (committed but unprocessed) or duplicate messages
Commit after processingauto commit off, commit after handler succeedsAt-least-once: duplicates on crash/rebalance, no loss
Transactional read-process-writeKafka transactions, consumer isolation.level=read_committedExactly-once for Kafka-to-Kafka
Store offsets with resultsSave offset in the sink DB in the same transaction; seek on startupExactly-once into that DB

Default recommendation: at-least-once plus an idempotent sink (upsert by key, dedupe table on event ID). Reach for transactions only for Kafka-to-Kafka processing where duplicates matter.

Exactly-Once Configuration

Producer side (transactional):

properties
enable.idempotence=true
acks=all
transactional.id=orders-enricher-0   # stable per producer instance

Consumer side:

properties
isolation.level=read_committed
enable.auto.commit=false

Kafka Streams: processing.guarantee=exactly_once_v2 (requires brokers 2.5+). Flink: checkpointing enabled plus KafkaSink with DeliveryGuarantee.EXACTLY_ONCE and a transactionalIdPrefix; downstream consumers must read with read_committed, and output becomes visible only when a checkpoint completes (latency is at least the checkpoint interval).

Exactly-once never extends to external side effects (emails, HTTP calls) automatically; those need idempotency keys.

Event Time, Watermarks and Windows

  • Event time = when it happened (timestamp in the event); processing time = when the operator sees it. Use event time for correctness under replay and lag.
  • A watermark asserts "no more events with timestamp < T are expected". Bounded-out-of-orderness watermark: max_seen_ts - allowed_lateness.
  • Windows fire when the watermark passes the window end. Late events beyond allowed lateness are dropped or sent to a side output.
  • Idle partitions hold back watermarks; configure idleness (WatermarkStrategy.withIdleness) in Flink.
java
// Flink DataStream API: 1-minute tumbling revenue per merchant, event time.
WatermarkStrategy<Order> wm = WatermarkStrategy
    .<Order>forBoundedOutOfOrderness(Duration.ofSeconds(30))
    .withTimestampAssigner((order, ts) -> order.occurredAtMillis())
    .withIdleness(Duration.ofMinutes(1));

DataStream<Order> orders = env.fromSource(kafkaSource, wm, "orders");

orders
    .keyBy(Order::merchantId)
    .window(TumblingEventTimeWindows.of(Duration.ofMinutes(1)))
    .allowedLateness(Duration.ofMinutes(5))
    .sideOutputLateData(lateTag)
    .aggregate(new SumRevenue())
    .sinkTo(revenueSink);

Stateful Processing

EngineState storeFault toleranceFits when
Kafka StreamsLocal RocksDB per task, backed by compacted changelog topicsChangelog restore; standby replicas speed recoveryKafka-in/Kafka-out logic embedded in a JVM service
FlinkHeap or RocksDB state backendPeriodic checkpoints / savepoints to object storageComplex event-time logic, large state, multiple sources/sinks
Spark Structured StreamingState store in executors, checkpoint to storageMicro-batch checkpointsTeams already on Spark; seconds-level latency acceptable

Rules:

  • Set state TTL for keyed state that would otherwise grow forever (e.g. per-user sessions).
  • Joins between two streams need a time bound (interval join) or state grows without limit.
  • Take a savepoint before changing job topology; assign stable operator UIDs in Flink so state maps across versions.

Throughput vs Latency Knobs

SettingHigher value gives
linger.msBigger batches, better throughput, more latency
batch.sizeLarger batches per partition
compression.type (lz4, zstd)Less network/disk, some CPU
fetch.min.bytes / fetch.max.wait.msFewer, larger fetches
max.poll.recordsMore records per poll; keep processing time under max.poll.interval.ms
Checkpoint interval (Flink)Less overhead, longer replay on failure and higher EOS output latency

Operations

  • Monitor consumer lag per partition (records and time), not only total.
  • Alert on under-replicated partitions, ISR shrink, and rebalance frequency.
  • Use cooperative rebalancing (partition.assignment.strategy=CooperativeStickyAssignor) or the new consumer group protocol (group.protocol=consumer, KIP-848) to avoid stop-the-world rebalances.
  • Schema registry with BACKWARD compatibility for every topic.

Anti-Patterns

Anti-patternFix
Processing time windows for business metricsEvent time + watermarks
Unkeyed messages where order mattersKey by entity ID
One partition "to keep order" for the whole topicOrder per key; partition for parallelism
Long blocking calls in poll loop -> rebalancesAsync with bounded in-flight, or raise max.poll.interval.ms deliberately
Unbounded state in joinsInterval joins, TTL
Claiming exactly-once with a non-transactional sinkIdempotent upserts or two-phase commit sink

Checklist

  • Partition key and count sized for peak and ordering.
  • RF=3, min.insync.replicas=2, acks=all for critical topics.
  • Commit strategy and sink idempotency documented.
  • Event-time watermarks, allowed lateness and late-data handling defined.
  • State TTL and checkpoint/savepoint procedure in place.
  • Lag, throughput and DLQ/late-data metrics alerting.

References

Tệp đi kèm

Mô hình đọc các tệp này khi cần trong lúc kỹ năng được tải. Các tệp được cung cấp ở dạng có thể đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Backend Data Streaming làm được gì?

Use this skill when the user says 'data streaming', 'kafka architecture', 'stream processing', 'flink job', 'kafka streams', 'exactly once', 'watermarks', 'windowed aggregation', 'consumer lag', 'log compaction'. Designs backend streaming pipelines on Kafka (or compatible logs) with Flink or Kafka Streams: partitioning, consumer groups, offset/commit strategy, stateful processing, event time and watermarks, and exactly-once configuration. Do NOT use for: simple pub/sub between services (backend-event-driven-architecture), broker selection for task queues (backend-message-queue), analytics w...

Vì sao nên dùng Backend Data Streaming trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Backend Data Streaming là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Backend Data Streaming trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/j4flmao/agent-skills/tree/main/skills/backend/universal/data-streaming. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm và cài đặt thành một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Backend Data Streaming?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Bạn có thể dùng Backend Data Streaming với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Backend Data Streaming với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Backend Data Streaming có miễn phí không?

Có. Kỹ năng này được j4flmao phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp cho mô hình các công cụ mới để gọi — mã được chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và tiêu chí của đầu ra tốt. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇