Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

GCP Pub/Sub Thread processing same task much slower than api call.

Any suggestions: deployed application on GCP cloud run. Same method which is processed in GCP pub sub consumer thread is taking 2min and in Api call to service is taking 1sec, Any idea why gcp pub sub thread is taking more time than service thread. Both API and pubsub is in same service.

1 1 111
1 REPLY 1

Hi @rahulChauhan,

Welcome to Google Cloud Community!

Based on my understanding, you noticed that processing a message via Pub/Sub introduces a delay, while a direct API call to the same service completes within 1 second.

The possible culprit could be related to the configuration or setup of your Cloud Run instances or Pub/Sub. Potential issues may also include network throttling and resource constraints.

Below are the possible solutions:

  • Check your Cloud Run and Pub/Sub logs to check if there are any errors related.
  • Try to adjust your instances for your Cloud Run service to eliminate cold starts.
  • If you are using batching, you may also want to consider reducing the batch size in Pub/Sub.
  • Check your network latency and ensure you have sufficient resources.
  • Configure your concurrency settings to ensure it can handle multiple messages concurrently.

If these steps don't resolve the issue, please reach out to Google Cloud Support. Their team has specialized expertise in diagnosing underlying problems. When contacting them, provide comprehensive details and relevant screenshots. This will help them better understand and address your issue.

I hope the above information is helpful.

Top Labels in this Space