常見開源消息系統
消息系統的作用:異步處理、削減峰值、減少組件之間的耦合。
選擇消息系統根據業務需要需要考慮以下幾個方面:
- 是否持久化
- 吞吐能力
- 高可用
- 分布式擴展能力
- 兼容現有協議
- 易于維護
- 其他,如消息丟失和重復的處理
- 避免單點故障
- 負載均衡 </ol>
- STOMP
- AMQP
- 類似 MEMCACHE 的協議
- HTTP
- 自定格式 </ol>
- 優先考慮持久化的設計,依靠 page cache 管理內存
- 高吞吐 112MB/s 11K msgs/s (比 beanstalkd >70x 吞吐能力)
- 支持異步復制
- 高可用、基于 Zookeeper 的集群設計、支持消費者失效后重新負載均衡
- Kafka 提供 PHP 類庫
- 支持 ganglia JMX 監控
- 需要策略避免重復消息, 消費者更新 Zookeeper 的 offset 的方式 (MetaQ 已經提供了幾種方式避免消息重復)
- MetaQ 提供 HTTP 接口 </ol>
- 追求簡單部署
- 追求高可用、避免單點故障、無中心設計
- 確保消息送達
- 生產者消費者自動發現、消費者連接所有生產者、向消費者推的模式
- 提供 HTTP 接口</p>
https://speakerdeck.com/snakes/nsq-nyc-golang-meetup
https://github.com/davegardnerisme/nsqphphttp://www.davegardner.me.uk/blog/tag/nsq/
3. Beanstalkd
- 支持持久化 binlog 設計,重啟消息不丟失
- 一般
- 無高可用設計
- 和 memcached 一樣的分布式擴展方式
- 各種類庫
- 有 Web 管理工具
- 支持同步調用,等待返回
- 只有類似 Memcache TCP ASCII 協議, 單文件部署
- 支持消息優先級
- 9K jobs/s 入隊列 5K jobs/s 出隊列
- 單點故障
- 無主從同步復制機制
- 最好單機多實例部署
https://github.com/kr/beanstalkd/wiki/Tools
https://github.com/pda/pheanstalk4. Redis
需要自己封裝 Pub/Sub
- 基于 Redis 的復制高可用
其他常見開源消息系統:
ZeroMQ: 輕量級基礎消息庫
只適合不需要持久化的場景、需要自己封裝
- 不支持持久化,只提供消息分發, 性能最好
- 無 Broker 設計, 無中心故障
RabbitMQ
- 2500 job/s 入隊列 1300 job/s 出隊列
- 適合小消息
- 分布式無單點設計
- 底層為 Erlang 實現
有評論: RabbitMQ could not enqueue/dequeue fast enough.
RESTMQ
MemcacheQ
http://memcachedb.org/memcacheq/
HTTPSQS
https://code.google.com/p/httpsqs/
Gearman
http://gearman.org/presentations
https://code.google.com/p/shard-query/Kestrel
http://robey.github.io/kestrel/
http://robey.github.io/kestrel/docs/guide.htmlHornetQ
性能差不考慮[3]
Resque
3800 jobs/s 入隊列 300 jobs/s 出隊列
https://github.com/blog/542-introducing-resque
基于 Redis 的消息隊列Starling
https://github.com/starling/starling
SquirrelMQ
https://code.google.com/p/squirrel-message-queue/
Sparrow – Ruby
https://code.google.com/p/sparrow/
Apache ActiveMQ
ActiveMQ crashed constantly under load.
STOMP HTTP 協議
http://stomp.github.io/stomp-specification-1.2.html
參考:
http://hiramchirino.com/stomp-benchmark/ec2-c1.xlarge/index.html
https://blog.serverdensity.com/queueing-mongodb-using-mongodb/
[3] http://x-aeon.com/wp/2013/04/10/a-quick-message-queue-benchmark-activemq-rabbitmq-hornetq-qpid-apollo/
https://news.ycombinator.com/item?id=5531192
http://www.javaplex.com/blog/high-performance-message-queues-get-reviewed/
來自:http://blog.eood.cn/mq
常見消息系統協議:
1、2 是不錯的可選開源組件:
1. Kafka/MetaQ: 廣泛用于 Linkedin 內部 (類似有 Java 版本的國產 MetaQ)
由于優先考慮吞吐,更加適合大數據量的消息收集和處理,比如日志分析、用戶行為信息實時報表、集群狀態信息收集和分析。
http://www.mail-archive.com/kafka-users@incubator.apache.org/msg02082.html
https://github.com/neophenix/StateOfTheMQ/blob/master/state_of_the_mq.pdf?raw=true
http://s.urge.omniti.net/i/content/slides/Surge2012-ErikOnen_Kafka_Messaging-Paradigms.pdf
http://research.microsoft.com/en-us/um/people/srikanth/netdb11/netdb11papers/netdb11-final12.pdf
http://dirlt.com/kafka.html
http://dirlt.com/index.html
http://wiki.secondlife.com/wiki/Message_Queue_Evaluation_Notes
2. NSQ – Golang
無中心設計、節點自動注冊和發現。可以考慮作為內部通訊框架的基礎。