常见开源消息系统/中间件技术评选

《常见开源消息系统/中间件技术评选》

Golang项目中MQ系统的选择

http://stackshare.io/stackups/rabbitmq-vs-nsq

RabbitMQ golang client

https://github.com/streadway/amqp

https://github.com/rabbitmq/rabbitmq-tutorials/tree/master/go

适用场景:高安全性、支付业务、稳定可靠、AMQP工业标准

gonsq

https://github.com/nsqio/nsq

http://nsq.io/

适用场景:弱事务,日志系统

kafka+flume

适用场景:日志、大数据

消息系统的作用

异步处理、削减峰值、减少组件之间的耦合。

  • 是否持久化
  • 吞吐能力
  • 高可用
  • 分布式扩展能力
  • 兼容现有协议
  • 易于维护
  • 其他,如消息丢失和重复的处理
  • 避免单点故障
  • 负载均衡

常见消息系统协议

  • STOMP
  • AMQP
  • MEMCACHE协议
  • HTTP
  • 自定格式

较好的开源系统列表

  • RabbitMQ
  • NSQ
  • Redis

NSQ 和 RabiitMQ的对比

NSQ

http://nsq.io/overview/quick_start.html nsq

无中心设计、节点自动注册和发现。可以考虑作为内部通讯框架的基础。

https://github.com/bitly/nsq * 追求简单部署 * 追求高可用、避免单点故障、无中心设计 * 确保消息送达 * 生产者消费者自动发现、消费者连接所有生产者、向消费者推的模式 * 提供 HTTP 接口

https://speakerdeck.com/snakes/nsq-nyc-golang-meetup https://github.com/davegardnerisme/nsqphp

http://www.davegardner.me.uk/blog/tag/nsq/

NSQ组合比较自由。

可以单独使用nsqd,Producer和Consumer自己直接连接nsqd。

也可以利用nsqlookupd来管理nsqd(根据心跳,挑选出可用的nsqd),Producer和Consumer跟nsqlookupd来交互。

======================================

RabbitMQ里面的Exchange类似nsqd,queen类似channel。

RabbitMQ

RabbitMQ

2500 job/s 入队列 1300 job/s 出队列 适合小消息 分布式无单点设计 底层为 Erlang 实现 有评论: RabbitMQ could not enqueue/dequeue fast enough.

https://blogs.vmware.com/vfabric/2013/04/how-fast-is-a-rabbit-basic-rabbitmq-performance-benchmarks.html

对于一个数据从Producer到Consumer的正确传递,还有三个概念需要明确:exchanges, queues and bindings。

    **Exchanges** are where producers publish their messages.

    **Queuesare** where the messages end up and are received by consumers

    **Bindings** are how the messages get routed from the exchange to particular queues.

还有几个概念是上述图中没有标明的,那就是Connection(连接),Channel(通道,频道)。

Connection: 就是一个TCP的连接。Producer和Consumer都是通过TCP连接到RabbitMQ Server的。以后我们可以看到,程序的起始处就是建立这个TCP连接。

Channels: 虚拟连接。它建立在上述的TCP连接中。数据流动都是在Channel中进行的。也就是说,一般情况是程序起始建立TCP连接,第二步就是建立这个Channel。

微信扫一扫交流

作者:ryanemax
微信关注:ryanemax (刘雨飏)
本文出处:https://romantic-hoover-f991f1.netlify.com/cookbook/backend/messagesystem/
授权协议: CC BY-SA 4.0