GOOGLE-PROFESSIONAL-CLOUD-DEVELOPER practice question 8 of 35

You need to redesign the ingestion of audit events from your authentication service to allow it to handle a large increase in traffic. Currently, the…

Full set: 265 questions
You need to redesign the ingestion of audit events from your authentication service to allow it to handle a large increase in traffic. Currently, the audit service and the authentication system run in the same Compute Engine virtual machine. You plan to use the following Google Cloud tools in the new architecture: Multiple Compute Engine machines, each running an instance of the authentication service Multiple Compute Engine machines, each running an instance of the audit service Pub/Sub to send the events from the authentication services. How should you set up the topics and subscriptions to ensure that the system can handle a large volume of messages and can scale efficiently?
Answer options
A: Create one Pub/Sub topic. Create one pull subscription to allow the audit services to share the messages. Correct answer
B: Create one Pub/Sub topic. Create one pull subscription per audit service instance to allow the services to share the messages.
C: Create one Pub/Sub topic. Create one push subscription with the endpoint pointing to a load balancer in front of the audit services.
D: Create one Pub/Sub topic per authentication service. Create one pull subscription per topic to be used by one audit service.
E: Create one Pub/Sub topic per authentication service. Create one push subscription per topic, with the endpoint pointing to one audit service.
Correct Answer:
A. Create one Pub/Sub topic. Create one pull subscription to allow the audit services to share the messages.
Explanation

This scenario requires a scalable, load-balanced system for processing messages. A single Pub/Sub topic serves as a centralized channel for all authentication services to publish audit events, effectively decoupling them from the consumers. A single, shared pull subscription allows the multiple audit service instances to act as a group of competing consumers. Each instance pulls messages from the subscription, and Pub/Sub ensures that any given message is delivered to only one instance for processing. This design distributes the workload evenly and allows the system to scale horizontally by simply adding more audit service instances to the subscriber pool without further configuration changes.

Why Incorrect

B: Creating a subscription per instance implements a fan-out pattern, causing each audit event to be processed multiple times by every service instance, which is incorrect for this use case. C: While a push subscription with a load balancer is a valid scalable pattern, the pull model is more idiomatic for backend workers on Compute Engine, giving them control over the message consumption rate. D: Creating a topic per authentication service is an anti-pattern that introduces unnecessary complexity and tight coupling, defeating the purpose of a decoupled messaging system. E: This option has the same flaws as D (unnecessary complexity and coupling) and incorrectly suggests a one-to-one mapping between publishers and subscribers, preventing load balancing.

References

1. Google Cloud Documentation, "Subscriber overview": Under the "Pull subscribers" section, it states, "When multiple subscribers receive messages from the same subscription, they are load-balancing. The subscribers can be running on different virtual machines." This directly validates the architecture described in option A for load balancing among a group of workers.

Source: https://cloud.google.com/pubsub/docs/subscriber, Section: "Pull subscribers".

2. Google Cloud Architecture Center, "Messaging with Pub/Sub for event-driven systems": This document describes common messaging patterns. The "Work queues" pattern is detailed as: "To distribute a workload across a set of workers, you can use a pull subscription. Each worker receives a subset of the messages." This is the exact pattern required by the question.

Source: https://cloud.google.com/architecture/messaging-with-pubsub-for-event-driven-systems, Section: "Common messaging patterns".

3. Google Cloud Documentation, "Receiving messages using Pull": "In a pull subscription, your subscriber application initiates requests to the Pub/Sub server to retrieve messages... This allows the subscriber to control the rate at which it receives messages." This highlights the control that pull subscribers (the audit services) have, which is beneficial for handling large, potentially spiky traffic.

Source: https://cloud.google.com/pubsub/docs/pull.

Scroll to Top