19

This question arises as I came across some mentions (such as this), about using a Messaging software such as ZeroMQ alongwith Redis, but I keep hearing about Redis itself used a messaging-system. So, if Redis is used along with other messaging systems, does it mean Redis has some serious deficiencies when used as a messaging system by itself ?

While the use of Redis for caching and pub/sub is clear to me, it is not clear if Redis can be used in place of a full-fledged messaging system such as JMS, AMQP or ZeroMQ.
Leaving alone the standards-compliance aspect and only concentrating on the functionality/features, does Redis provide support for all the messaging patterns/models required of a messaging system ?

The messaging patterns I am talking about are :

  1. RPC/Request-reply (an example using ActiveMQ/JMS and another using RabbitMQ/AMQP)
  2. Pipeline/Work queues (once and atmost once consumption of each message)
  3. Broadcast (everyone subscribed to the channel)
  4. Multicast (filtering of messages at server based on consumers' selectors)
  5. Any other messaging pattern ?

If yes, then Redis seems to solve two (possibly more) aspects at once: Caching and Messaging.

I am looking at this in the context of a web-application backed by a Java/Java EE server. And I am looking at this not from a proof-of-concept point-of-view but from a large-scale software development angle.

Edit1:
user:791406 asked a valid question:

"Who cares if redis supports those patterns; will redis meet your SLA and QoS needs?"

I thought it is better to give this detail as part of the question instead of in the comments section.

My current needs are less to do with SLA and QOS and more to do with choosing a tool for my job (messaging) that I can use even when my requirements grow (reasonably) in future. I am starting with simplistic requirements at first and we all know requirements tend to grow. And NO, I am not looking for a one tool that does it all. I just want to know if Redis fulfills the usual requirements expected out of a messaging system, like ActiveMQ/RabbitMQ does. Ofcourse, if my SLA/QOS needs are extreme/eccentric, I would need to get a special tool for satisfying that. For ex: In some cases ZeroMQ could be chosen over RabbitMQ due to specific SLA requirements. I am not talking about such special requirements. I am focusing on average enterprise requirements.

I was afraid (based on my little understanding) that eventhough redis could be used as a basic tool for my messaging needs of today, it might be the wrong tool for a real messaging job in future. I have experiences with messaging systems like ActiveMQ/RabbitMQ and know that they could be used for simple to (reasonably) complex messaging needs.

Edit2:

  1. The redis website mentions "Redis is often used as a messaging server" but how to achieve the messaging patterns is not clear.

  2. Salvatore sanfilippo mentions Redis users tend to use it as a database, as a messaging bus, or as a cache. To what extent can it serve as a "messaging bus" is not clear.

  3. When I was trying to find out what messaging requirements of JMS that redis doesnt support, I came across something that Redis supports but JMS doesnt: Pattern-matching subscriptions i.e Clients may subscribe to glob-style patterns in order to receive all the messages sent to channel names matching a given pattern.

Conclusion:

I have decided to use JMS for my messaging needs and use Redis for Caching.

4

1 回答 1

18

你需要什么?

我认为您应该问自己的问题是“我需要什么质量的消息来支持我的应用程序?” 在决定消息传递平台之前。谁在乎 redis 是否支持这些模式?redis 会满足你的 SLA 和 QoS 需求吗?首先关注这一点,然后根据该评估做出您的技术决策。

话虽如此,我将就您如何做出该决定提供我的意见...

高度可靠/持久/持久的消息传递
让我们举一个极端的例子:假设您正在构建一个交易或金融应用程序。此类应用程序需要严格的 SLA,其中消息持久性、可靠性、一次性交付和持久性是最重要的。在这种情况下,使用 redis 作为消息传递主干可能是一个糟糕的选择,原因有很多......

  • 消息重新传递(当 sh*t 击中风扇时)
  • Redis 宕机时的消息存储复制
  • 消息事务(redis 不能做 XA)
  • 生产者/订阅者容错和断开连接弹性
  • 消息顺序排序
  • 在代理关闭时发送消息(存储转发)
  • 单线程redis可能会成为瓶颈

如果您的系统有严格的 SLA,这些问题中的一些或全部肯定会出现,那么您将如何处理这些限制?您可以围绕 redis 实现自定义代码来解决一些问题,但是当 ActiveMq、WebsphereMQ 和 WebLogic JMS 等成熟的消息传递平台提供持久性、可靠性和容错性时,何必费心呢?您说您使用的是 Java/Java EE 堆栈,因此您可以使用一些可用的最强大的消息传递框架,无论是开源的还是商业的。如果您正在进行金融交易,那么您需要考虑这些选项。

高性能/大型分布式系统消息传递
如果您正在构建一个社交网络或游戏平台,您希望性能胜过可靠性,ZeroMq 可能是一个不错的选择。它是一个封装在类似消息传递 API 中的套接字通信库。它是去中心化的(无代理),速度非常快,并且具有高弹性和容错性。如果您需要使用代理中介执行 N 对 N 发布/订阅、流控制、消息持久性或点对点同步等操作,ZeroMq 提供了必要的工具和代码示例,可以用最少的代码完成所有操作,同时避免从头开始构建解决方案。它是用 C 编写的,但具有几乎所有流行语言的客户端库。

希望有帮助...

于 2013-05-15T18:26:48.263 回答