
Answer-first summary for fast verification
Answer: Deploy your code on Cloud Functions. Use a Pub/Sub trigger to handle new messages in the topic.
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.
Author: LeetQuiz Editorial Team
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)?
A
Deploy the application on Compute Engine. Use a Pub/Sub push subscription to process new messages in the topic.
B
Deploy your code on Cloud Functions. Use a Pub/Sub trigger to invoke the Cloud Function. Use the Pub/Sub API to create a pull subscription to the Pub/Sub topic and read messages from it.
C
Deploy the application on Google Kubernetes Engine. Use the Pub/Sub API to create a pull subscription to the Pub/Sub topic and read messages from it.
D
Deploy your code on Cloud Functions. Use a Pub/Sub trigger to handle new messages in the topic.
No comments yet.