当K8制作HPA时,如何避免在酒吧/子中重复消息?
我有以下架构。
我有一个微服务订阅的Redis Pub/sub,有时候负载会很高,我需要在K8S中进行水平POD Autoscaler,以便处理所有酒吧/子消息,同时保持低潜伏期。
问题是,如果我使用pub/sub,每个豆荚将处理消息,如果使用队列,则需要将POD进行进行轮询以读取所有消息,因此,如何使用模式或模式或我需要使用还是知道?
谢谢。
I have the following architecture.
I have a microservice that is subscribed to a Redis pub/sub, sometimes at the day the load will be high and I will need to make a horizontal pod autoscaler in K8S, in order to process all pub/sub messages while keeping the low latency.
The problem is that if I use pub/sub the message will be processed by each pod, and if use a queue the pods will need to make polling to Redis in order to read all messages, so, how can I scale that with pattern or approach I need to use or to know?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想拥有微服务的多个实例来处理已发布的其他消息(为了更快地排出队列或保持低延迟),那么Redis Pub/sub不是此处的选择,因为它具有风扇 - OUT设计,这意味着将向所有订户发送相同的已发布消息。
您需要的是 rabbitmq 或Amazon sqs ,使您可以将多个消费者连接到同一队列,并且每个消费者正在处理不同的消息。
SQS中的一个非常有用的功能是,当消费者接收消息时,有一个可配置的时间框架,称为可见性超时,在此期间,其他消费者看不到该消息(因此,对其进行处理)。如果最初接收消息的消费者不会在该时间范围内将其从队列中删除,则该消息将提供给其他消费者。
If you want to have multiple instances of your microservice to process a different message that was published (in order to drain the queue faster or keep a low latency), then Redis pub/sub is not the right choice here, because it has a fan-out design, which means that the same published message will be dispatched to all subscribers.
What you need here is RabbitMQ or Amazon SQS, that allow you to have multiple consumers connected to the same queue, and each consumer is processing a different message.
A very useful feature in SQS, is that when a consumer takes a message, there is a configurable timeframe called visibility timeout, during which other consumers cannot see that message (and thus, process it). If the consumer that initially took the message does not remove it from the queue within that timeframe, then the message will be available to other consumers.