云发布订阅慢轮询率 [英] Cloud pubsub slow poll rate

查看:95
本文介绍了云发布订阅慢轮询率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个pubsub主题,有一个订阅,并且有两个不同的订阅者正在从中进行订阅. 使用stackdriver,我可以看到订阅有〜1000条消息. 每个订户运行以下轮询循环:

I have a pubsub topic, with one subscription, and two different subscribers are pulling from it. Using stackdriver, I can see that the subscription has ~1000 messages. Each subscriber runs the following poll loop:

client = pubsub.Client()
topic = client.topic(topic_name)
subscription = pubsub.Subscription(subscription_name)

while True:
    messages = subscription.pull(return_immediately=True, max_messages=100, client=client)
    print len(messages)
    # put messages in local queue for later processing. Those processes will ack the subsription

我的问题是轮询速度很慢-即使我有很多消息等待轮询,但每次都只会收到几条消息.同样,许多回复都返回了,没有任何消息.根据stackdriver的说法,我的邮件提取速度约为1.5邮件/秒.

My issue is a slow poll rate - even though I have plenty of messages waiting to be polled, I'm getting only several messages each time. Also, lots of responses are back without any messages. According to stackdriver, my messages pulled rate is ~1.5 messages/sec.

我尝试使用return_immediately=False,并对其进行了一些改进-拉速增加到〜2.5消息/秒,但是-仍然不是我期望的速度.

I tried to use return_immediately=False, and it improved it a bit - the pull rate increased to ~2.5 messages/sec, but still - not the rate I would expect to have.

任何想法如何提高牵引率?有pubsub民意调查的最佳做法吗?

Any ideas how to increase pull rate? Any pubsub poll best practices?

推荐答案

为了提高拉取速度,您一次必须具有多个未完成的拉取请求.多少取决于您发布的速度和速度.您将始终需要至少一些优秀的人才.一旦其中一个返回,就创建另一个拉取请求.这样,每当Cloud Pub/Sub准备好将消息传递给订户时,您都有等待接收消息的请求.

In order to increase your pull rate, you need to have more than one outstanding pull request at a time. How many depends on how fast and from how many places you publish. You'll need at least a few outstanding at all times. As soon as one of them returns, create another pull request. That way, whenever Cloud Pub/Sub is ready to deliver messages to your subscriber, you have requests waiting to receive messages.

这篇关于云发布订阅慢轮询率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆