question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Google Cloud Pub/Sub triggers high latency on low messages throughput

See original GitHub issue

i’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:open
  • Created 3 years ago
  • Reactions:2
  • Comments:25 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ChrisWestcottUKcommented, Feb 16, 2022

One thing that appeared to have also occurred at this time was messages published multiple times (we’re using an orderingKey):

Doesn’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?

1reaction
kamalaboulhosncommented, Feb 15, 2022

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found