Skip to content
cccskills
FreePublished on GitHub

kafka-best-practices

Apache Kafka 4.2 best practices for event streaming, topic design, and producer-consumer patterns

The English summary is being prepared. Showing the original description.

See how to install

Files included (1)

  • SKILL.md1.7 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

Apache Kafka Best Practices

Version: Kafka 4.2.0. ZooKeeper is fully removed in Kafka 4.x — use KRaft mode for all cluster deployments.

Producer Patterns

Idempotent Producer (CRITICAL)

  • Enable enable.idempotence=true
  • Prevents duplicate messages
  • Requires acks=all, retries > 0, max.in.flight.requests.per.connection <= 5

Exactly-Once Semantics

  • Use transactional API: initTransactions(), beginTransaction(), commitTransaction()
  • For exactly-once end-to-end processing

Performance

  • Batching: linger.ms (wait for batch to fill)
  • Compression: compression.type=snappy or lz4
  • batch.size: 16KB default, tune based on message size

Consumer Patterns

Offset Management

  • Auto-commit: enable.auto.commit=true (at-least-once)
  • Manual commit: commitSync() or commitAsync() (better control)

Rebalancing

  • Cooperative sticky assignor: minimal rebalancing disruption
  • session.timeout.ms and heartbeat.interval.ms tuning

At-Least-Once vs Exactly-Once

  • At-least-once: default, idempotent processing required
  • Exactly-once: transactional consumer + producer

Topic Design

Partitioning

  • Partition count: based on throughput (MB/s ÷ partition throughput)
  • Key-based partitioning for ordering guarantees
  • More partitions = higher throughput (but more overhead)

Retention

  • Time-based: retention.ms
  • Size-based: retention.bytes
  • Log compaction: for changelog topics (cleanup.policy=compact)

References

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

Pre-action boundary checking — validates agent tool calls against declared capabilities and task contracts

The English summary is being prepared. Showing the original description.

baekenough/second-brain15Updated Oct 8, 2026

Auto-detect project context and optimize harness — deactivate unused agents/skills, suggest missing experts, generate project profile

The English summary is being prepared. Showing the original description.

baekenough/second-brain15Updated Oct 8, 2026

Adversarial code review using attacker mindset — trust boundary, attack surface, business logic, and defense evaluation

The English summary is being prepared. Showing the original description.

baekenough/second-brain15Updated Oct 8, 2026

Apache Airflow best practices for DAG authoring, testing, and production deployment

The English summary is being prepared. Showing the original description.

baekenough/second-brain15Updated Oct 8, 2026

Alembic migration patterns for naming conventions, safety checks, expand-contract, env.py configuration, and CI integration

The English summary is being prepared. Showing the original description.

baekenough/second-brain15Updated Oct 8, 2026

Pre-routing ambiguity analysis — scores request clarity and asks clarifying questions when needed (inspired by ouroboros)

The English summary is being prepared. Showing the original description.

baekenough/second-brain15Updated Oct 8, 2026

See all skills by baekenough

Report a problem with this skill