Asynchronous triggers to multiple google cloud functions

Viewed 310

I have a java application that interacts with multiple cloud functions which need to be triggered when an event occurs. The cloud functions need to be triggered asynchronously. I read that Pub/Sub is an option to asynchronously trigger Cloud Functions but I cannot use it due to some architectural constraints.

I tried the http trigger but I need to wait until it is completed before I trigger my other Cloud functions.

Is there any alternative method for Pub/Sub trigger?

2 Answers

Google pubsub can be used for your need of triggering cloud functions asynchronously. The pub/sub does not guarantee order. Google pubsub is applicable for typical use cases where ordering is not a concern.

The Google Cloud Functions can be trigerred with a HTTP request. But, HTTP trigger works only synchronously.

Though pub/sub is more suitable for aynchronous requirement, it is still possible to bring in synchronous support, but at cost of throughput / performance. One of the method is assigning the message a unique identifier by sender which can be processed accordingly at receiver. Another approach can be using cloud monitoring for determining whether there are messages it has not yet received by tracking unacked metric.

But if your solution needs high availability and scalability, it is recommended to minimize dependency on order.

The alternative method for Pub/Sub trigger depends on your exact limitation that you are facing coupled with architectural, deployment requirement.

Not really.

With HTTP triggers, the client app needs to wait for a response synchronously.

With all other types of functions (including pubsub triggers), they are invoked asynchronously.

It's not clear what your "architectural constraints" are. But you can certainly accept a unit of work through an HTTP trigger, then delegate it asynchronously to a pubsub trigger, and return some unique ID for the client to use to poll for results (if needed).

Related