Dynamically Create Cloud Run or Function determined by attribute in pub/sub

I am trying to get a Cloud Run or Cloud Function to start and pull out messages that match its defined ID, for example, if a message with attribute ID 1 is put into the topic, The Cloud Run with ID 1 will take it out, it's important that all messages with attribute 1 go to the same instance. I understand I could use filters on the subscriptions but I would like to able to easily change the amount of possible ID's, e.g. If I only put messages in the topic with ID's ranging between 0 and 4 then only five instances would be started. How would I go about creating something like this? Does Pub/Sub support this sort of functionality? I know I could create X amount of topics and then put each message into its own topic but that seems like a inefficient way of executing this when there is the attribute system.

 

Proposed SystemProposed System

Solved Solved
0 1 139
1 ACCEPTED SOLUTION

To answer if Pub/Sub supports the functionality you discussed on your question, the straightforward answer is No. Pub/Sub's  usual use cases are stream analytics of fluctuating volumes of real-time data and messaging middleware for traditional service integration or a simple communication medium for modern microservices. It has no capability in starting a Cloud Run instance.

I would also like to share you the behavior and criteria of Cloud Run autoscaling in this GCP Documentation, just to give you an idea that it auto-scales depending on the needed instances to handle all incoming requests or events. You may also set maximum container instances.

 

 

View solution in original post

1 REPLY 1

To answer if Pub/Sub supports the functionality you discussed on your question, the straightforward answer is No. Pub/Sub's  usual use cases are stream analytics of fluctuating volumes of real-time data and messaging middleware for traditional service integration or a simple communication medium for modern microservices. It has no capability in starting a Cloud Run instance.

I would also like to share you the behavior and criteria of Cloud Run autoscaling in this GCP Documentation, just to give you an idea that it auto-scales depending on the needed instances to handle all incoming requests or events. You may also set maximum container instances.