Google Professional Cloud Developer Question 58
Single answerGoogle Cloud PlatformYour team is building a distributed e-commerce application on Google Cloud. You want to implement an order processing system that can handle high volumes of orders asynchronously while ensuring that order events are not lost. The system must be loosely coupled to allow independent scaling of the order service and the payment service. Which approach should you take?
- A
Use Pub/Sub to publish order events from the order service, and have the payment service subscribe to the topic to process the events.
- B
Use a Cloud SQL database to store the order events and have the payment service poll the database for new orders.
- C
Implement a tightly coupled REST API between the order service and the payment service to directly communicate order details.
- D
Use Eventarc to trigger the payment service whenever the order service writes a new order event to Cloud Storage.
Show answer and explanation
Correct answer: A
Explanation
The best approach for this scenario is to use Pub/Sub, as it is specifically designed for building loosely coupled, asynchronous applications. It supports reliable message delivery, independent scaling of producers and consumers, and high throughput, making it an ideal choice for handling high volumes of order events in a distributed system.
- A. Correct.
This is the correct answer. Pub/Sub is a managed service designed for asynchronous communication between microservices. It ensures loosely coupled components, reliable delivery of messages, and independent scaling of services.
- B. Incorrect.
This is not a suitable solution as polling a database for new events is inefficient, introduces latency, and tightly couples the services. Moreover, databases are not designed for event-driven communication.
- C. Incorrect.
This is incorrect because using a tightly coupled REST API violates the requirement for loose coupling. Any changes in one service would directly impact the other, and it does not handle asynchronous processing effectively.
- D. Incorrect.
While Eventarc can trigger services based on events, using Cloud Storage as the event source for order processing is not optimal. It introduces unnecessary complexity and does not align with the requirements for high-volume, asynchronous event handling.