Google Professional Cloud Developer Question 55
Single answerGoogle Cloud PlatformYou are developing a cloud-native e-commerce application hosted on Google Cloud. The application needs to notify multiple downstream services (e.g., inventory management, order fulfillment, and analytics) whenever a new order is placed. The notifications must be processed asynchronously, and the system should remain loosely coupled to ensure scalability and maintainability. Which solution should you implement?
- A
Use Pub/Sub to publish order events, and have each downstream service subscribe to the topic.
- B
Use a Cloud SQL database to store order events, and have each downstream service poll the database for new orders.
- C
Implement a REST API endpoint for each downstream service, and make synchronous HTTP calls to notify them when an order is placed.
- D
Use a Cloud Storage bucket to store order events as files, and have downstream services monitor the bucket for new files.
Show answer and explanation
Correct answer: A
Explanation
Pub/Sub is the best solution for building loosely coupled, asynchronous applications in Google Cloud. It allows the e-commerce application to publish order events to a topic, which can be subscribed to by multiple downstream services. This design ensures scalability, fault tolerance, and minimal dependencies between services, making it ideal for event-driven architectures.
- A. Correct.
This is the correct solution because Pub/Sub is designed for asynchronous event-driven communication. It ensures loose coupling between the publisher (order service) and subscribers (downstream services), enabling scalability and independent development of services.
- B. Incorrect.
This is not an ideal solution because polling a database increases latency and creates unnecessary load on the database. It also couples the downstream services to the database's schema, reducing maintainability.
- C. Incorrect.
This is not a good solution as making synchronous HTTP calls introduces tight coupling between the services and doesn't provide the benefits of asynchronous processing. It can also lead to delays or failures if any downstream service is unavailable.
- D. Incorrect.
Using Cloud Storage for event notifications is not a best practice in this scenario. While it may work, it introduces unnecessary complexity and latency, as well as limitations in event processing compared to Pub/Sub.