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.

Pub/Sub access to message ack id in the subscribe use case

See original GitHub issue

When pulling messages, we get ReceivedMessage that contains the ack id that can then be used to ack multiple messages at once using the ModifyAckDeadlineRequest.

However, on the subscribe side all we get is PubsubMessage and AckReplyConsumer, without access to the ack id of the message. So, this means that we cannot ack messages in batch.

@garrettjonesgoogle

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
kamalaboulhosncommented, Feb 15, 2020

@unoexperto Relatively speaking, I expect the AckReplyConsumer is going to be much smaller than the messages you are buffering themselves, so I don’t think holding on to them is going to be a major contributing factor to OOMs. However, holding on to messages for an hour in a subscriber client and only acking after a batch is flushed is an anti-pattern for Cloud Pub/Sub. You want to try to ack messages very quickly. The longer you wait to ack, the more risk there is of duplicate delivery, which would also waste resources. You’d be better off writing messages to some persistent storage locally when you receive them, acking them, and then flushing the data every hour. You could do this using Apache Beam/Cloud Dataflow.

0reactions
unoexpertocommented, Feb 15, 2020

@pongad @kamalaboulhosn This is very limiting factor. Could you please suggest how one can postpone acking bunch of messages? I’m using PubSub as durable storage of messages which I batch into 1 hr chunks and send elsewhere. I don’t want to accept messages until I’m sure my consumer got the batch. I could of course hold on to instances of AckReplyConsumer for each message in the batch that I haven’t processed yet but it poses risk of OOM exception as you point out in documentation.

Because the client library repeatedly extends the acknowledgement deadline for backlogged messages, those messages continue to consume memory, CPU, and bandwidth resources. As such, the subscriber client might run out of resources (such as memory). This can adversely impact the throughput and latency of processing messages.

What would you suggest?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pull subscriptions | Cloud Pub/Sub Documentation
In pull delivery, your subscriber application initiates requests to the Pub/Sub server to retrieve messages. You can use the pull mode to perform...
Read more >
Subscribe to Messages from a Topic - Go CDK
The Go CDK can receive messages from a Google Cloud Pub/Sub subscription. The URLs use the project ID and the subscription ID. pubsub....
Read more >
Things I wish I knew about Google Cloud Pub/Sub: Part 2
First, a publisher sends a message to the topic. Once the Pub/Sub server receives the message, it adds fields to the message such...
Read more >
Subscribers · DEoGC - rindra
Call the acknowledge method to indicate that the subscriber has finished processing the message and that the Pub/Sub server can delete it from...
Read more >
Package pubsub - ActiveGo 1.8.3 Documentation
Ack has been called. Client code must be robust to multiple deliveries of messages. Deadlines ¶. The default pubsub deadlines are suitable for...
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