Google Professional Cloud Developer

Google Professional Cloud Developer

Get started today

Ultimate access to all questions.


How should you design an event-driven architecture using Pub/Sub where messages are processed in real time, with the application being self-contained and cost-effective (only incurring charges when new messages arrive)?




Explanation:

The question requires an architecture that processes Pub/Sub messages in real time, is independent of other systems, and incurs costs only when messages arrive. Cloud Functions is serverless, scales to zero, and charges only per invocation, meeting the cost requirement. Option D uses a Pub/Sub trigger, which automatically creates a push subscription to invoke the function when messages arrive. This ensures real-time processing without active infrastructure management. Options A and C involve Compute Engine or GKE, which require persistent resources and incur costs even when idle. Option B incorrectly combines a Pub/Sub trigger with a pull subscription, which would require active polling (not serverless-triggered). Thus, D is the correct answer.