Kafka要点解析

什么是Kafka

Kafka是LinkedIn用scala开发的,基于发布/订阅的分布式消息系统,以易水平扩展和高性能特征著称。

Kafka常用术语

Kafka要点

关于partition

# The minimum age of a log file to be eligible for deletion
log.retention.hours=168

# A size-based retention policy for logs. Segments are pruned from the log as long as the remaining
# segments don't drop below log.retention.bytes.
#log.retention.bytes=1073741824

# The maximum size of a log segment file. When this size is reached a new log segment will be created.
log.segment.bytes=1073741824

关于replication和leader election

关于消息可靠性传输

消息可靠性一般分为三种:

  1. At least once:消息不会丢,但可能会重复
  2. At most once:消息可能会丢,但不会重复
  3. Exactly once:既不会丢也不会重复

Kafka默认保证了At least once

当若想实现Exactly once,则需要配合持久化和offset来实现。