Skip to content

Instantly share code, notes, and snippets.

@taozle
Last active September 20, 2016 03:50
Show Gist options
  • Save taozle/3e2c05ce48ad69f9c1e0b598548d9412 to your computer and use it in GitHub Desktop.
Save taozle/3e2c05ce48ad69f9c1e0b598548d9412 to your computer and use it in GitHub Desktop.

From Kafka to ZeroMQ for real-time log aggregation

Kafka

架构图:

Problems

Over the year we have experienced several failures where the Kafka/Zookeeper combo struggled to rejoin the cluster after VM recycle, with a domino effect on the entire logging system.

  • 相对于吞吐量和性能更加关注高可用
  • 实践中经历过几次高可用故障
  • Kafka 高可用不容易搞,小公司没那么多精力

Rethink

只是想要聚合以及实时展示日志,不太在意是不是可以访问历史日志

ZeroMQ

Kafka VS ZeroMQ

一般来说这两个没什么可比的

Topics and Messages

  • Kafka 原生支持
  • ZeroMQ 没有 Topic 概念,但是有 subscription filter

Delevery guarantees

  • Kafka 本身可以保证 at-least-once delivery
  • ZeroMQ 在没有订阅者并且内存 Buffer 满的时候会丢消息

Durable state and performance

  • Kafka 将消息存储在 Disk 中,所以可以保证 Delivery 以及消息回放
  • ZeroMQ 将消息存在内存中,所以没有回放
  • 显而易见的,ZeroMQ 比 Kafka 快

Stability

  • Kafka 的稳定性不够好(有状态)
  • 为了让 Kafka 稳定,需要配合 HA、Zookeeper
  • 使用 ZeroMQ 之后架构变得简单了,所以更稳定了(状态短暂)

如何持久化呢?

其实很简单,添加一个 subscriber,把订阅的消息发送到 ELK or AWS Kinesis.

感受

  • We should always prefer a simple design.
  • 小团队不需要追求高大上的架构,应该选择满足自己当前需求的架构,避免额外复杂

参考资料

  1. https://tomasz.janczuk.org/2015/09/from-kafka-to-zeromq-for-log-aggregation.html?term=12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment