You need real-time processing of Pub/Sub messages, with the application independent of other systems and incurring cost only when messages arrive. How should you configure the architecture?
Choose an answer
Tap an option to check your answer.
Correct answer: Deploy code to Cloud Functions and use a Pub/Sub trigger to handle new messages..
Why this is the answer
The correct approach is to deploy code to Cloud Functions with a Pub/Sub trigger. Cloud Functions are serverless, meaning they automatically scale and you only pay for the compute time when your function executes in response to a message. This directly addresses the requirement for cost incurrence only when messages arrive and provides real-time processing. A Pub/Sub trigger automatically invokes the function for each new message, ensuring independence from other systems. Deploying on Compute Engine or GKE would involve running persistent instances, leading to continuous costs regardless of message volume, violating the "cost only when messages arrive" constraint. While a pull subscription is possible, the Pub/Sub trigger on Cloud Functions is a more direct and efficient serverless pattern for real-time processing of Pub/Sub messages. Creating a pull subscription via the API in addition to a Pub/Sub trigger for Cloud Functions is redundant and unnecessary.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed