Google Cloud Pub/Sub triggers high latency on low messages throughput
See original GitHub issuei’m running project which publishes messages to a PubSub topic and triggers background cloud function.
I read that with high volumes of messages, it performs well, but for lesser amounts like hundreds or even tens of messages per second, Pub/Sub may yield high latencies.
Code example to publish message:
const {PubSub} = require('@google-cloud/pubsub');
const pubSubClient = new PubSub();
async function publishMessage() {
const topicName = 'my-topic';
const dataBuffer = Buffer.from(data);
const messageId = await pubSubClient.topic(topicName).publish(dataBuffer);
console.log(`Message ${messageId} published.`);
}
publishMessage().catch(console.error);
Code example of function triggered by PubSub:
exports.subscribe = async (message) => {
const name = message.data
? Buffer.from(message.data, 'base64').toString()
: 'World';
console.log(`Hello, ${name}!`);
}
Environment details
- OS: Windows 10
- Node.js version: 8
@google-cloud/pubsub
version: 1.6
The problem is when using PubSub with low throughput of messages (for example, 1 request per second) it struggles sometimes and shows incredibly high latency (up to 7-9s or more).
Is there a way or workaround to make PubSub perform well each time (50ms or less delay) even with small amount of incoming messages?
Thanks!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:25 (2 by maintainers)
Top Results From Across the Web
Google Cloud Pub/Sub triggers high latency on low messages ...
The problem is when using PubSub with low throughput of messages (for example, 1 request per second) it struggles sometimes and shows incredibly ......
Read more >Pub/Sub: A Google-Scale Messaging Service
This section explains the design of Pub/Sub to show how the service attains its scalability and low latency while retaining availability. The system...
Read more >Fine-tuning Pub/Sub performance with batch and flow control ...
Google Cloud Pub/Sub is often used as an event digestion and delivery service ... low end-to-end latency and high throughput at the expense...
Read more >Benchmarking Kafka and Google Cloud Pub/Sub Latencies
At higher throughputs the latencies dropped to 300-400ms. This conforms to Google's documentation and generally accepted knowledge that Pub/Sub ...
Read more >Ably vs Google Cloud Pub/Sub
Ably Google Cloud Pub/Sub
Global datacenters locations 7 56 zones
Latency based routing
Binary encoded messages Limited
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
One thing that appeared to have also occurred at this time was messages published multiple times (we’re using an
orderingKey
):eventId
as an idempotency key: https://cloud.google.com/blog/products/serverless/cloud-functions-pro-tips-retries-and-idempotency-in-actioneventId
is the message id: https://cloud.google.com/functions/docs/calling/pubsub#event_structureDoesn’t that show that it’s important to choose good idempotency keys and not follow the suggestions in the documentation? Or is there something I’m missing?
@ChrisWestcottUK The release notes for the server only track significant API/region availability/feature availability changes, not every server change that is made. There is no public tracking for all of these such changes. For tracking issues if they affect your projects, it is best to put in a support request so support engineers can follow up. This particular incident should now be resolved.