trigger cloud function directly or put in pub sub queue to trigger

I want to trigger a cloud function after receiving payment to continue processing an order...
Is there any reason to place a message in a pub sub queue rather than triggering the function directly?

0 2 73
2 REPLIES 2

Hello @decentgradient,

Welcome to Google Cloud Community!

Take a look at the documentation: Pub/Sub triggers. When you specify a Pub/Sub trigger for a function, you also specify a Pub/Sub topic. Your function will be called whenever a message is published to the specified topic.

Additionally, you can take a look at Cloud Function and Pub/Sub to better understand their difference. 

You can also contact Google Cloud Support to further look into your query. Hope it helps, thanks!

What are some reasons you're thinking of for using a queue?

Cloud Functions scale very well to even a large number of invocations at the same time. There's no need for a PubSub queue if the goal is to manage Cloud Functions capacity.

A reason to use a PubSub queue (or Cloud Tasks) could be if you have a downstream resource that the function calls, and that resource can't deal well with too many requests in parallel.

I think there might be other use cases around decoupling systems and having multiple subscribers to that queue.

But the simplest thing here is: don't use a queue; you can always add one later if you find a need for it.