Simplification in Architecture
RocketMQ uses nameserver instead of ZooKeeper (for service registration, discovery, distributed locks, and configuration management) to reduce overhead.
The underlying implementation of persistence is different:
- Kafka: Each partition stores the complete message. The underlying storage is composed of multiple segments. Since Kafka writes to small files sequentially, when there is only one segment or multiple partitions, sequential writes may turn into random writes.
- RocketMQ: Each partition only stores brief information (offset). All topics' persistence is written to a single commit log, which simplifies the design.
Simplified Backup Model
- Kafka: Partitions are divided into leaders and followers, with full data backup.
- RocketMQ: How does RocketMQ back up data? By taking snapshots, similar to RDB (Redis Database Persistence).
Adding Features
- Message Classification: RocketMQ supports tagging messages. Consumers can filter messages based on tags.
- Transactions: RocketMQ supports transactions. Producers execute local business logic and send messages. The transaction either commits successfully or rolls back, ensuring atomicity with half-message transactions.
- Delay Queue & Dead Letter Queue: RocketMQ supports both.
Domestic MQ Solutions
There is a demand for domestic MQ solutions in China, with the “Xinchuang” (Information Technology Application Innovation Industry) initiative encouraging domestic alternatives. For example, replacing RocketMQ with another solution, such as Redis.
- Redis' Stream data structure can be used to implement a message queue. By adding service discovery and other features, the ideas of RocketMQ can be adapted to implement delay queues and message queues.
Performance Comparison
- RabbitMQ: Released in 2007, it’s written in Erlang and supports microsecond-level latency.
- RocketMQ and Kafka: Both support millisecond-level response times. Therefore, RocketMQ is Java-based. If you are unfamiliar with the source code, it might be faster to work with it directly, without the need to switch languages.
If there are any issues with the tweet, please feel free to discuss them with me:)
架构上做减法
Rocket使用namesever代替了zookeeper(注册发现+分布式锁+配置管理)来减少开销
持久化的底层实现不一样,kafka是每个partition都存的是完整消息底层是每个segment组成,因为他对每个小文件都是顺序写,如果只有一段还好多段partition,顺序写会变成随机写,而RoketMQ每个partition的是简要信息(offset) ,所有topic持久化都落在一个commitlog上,
简化备份模型 kafka是 partition分为leader和follower,全量备份数据,
RocketMQ如何备份数据?
打快照,类似RDB
功能上做加法
支持消息分类 打tag,消费者根据tag过滤数据
RocketMQ支持事务 ,生产者执行本地业务逻辑和生产者发消息,要么同时成功要么同时回滚,半消息事务。
RocketMQ支持延迟队列、死信队列
企业上有一个问题 国产MQ需求,信创(即信息技术应用创新产业)用国产代替方案,比如将RocketMQ换一个方式去实现,比如Redis
Redis 的Stream数据结构可以实现消息队列,再给他外加一些注册发现之类,借鉴rocketmq的思想去实现延时队列、消息队列。
RabbitMQ是07年出的消息队列,erlang语言编写,支持us级别,而RocketMQ和Kafka支持ms级的响应
所以RocketMQ是Java写的,如果遇到不懂得看源码会更快一点不用去进行语言切换。
Top comments (0)