Google Professional Cloud Developer Question 12
Single answerGoogle Cloud PlatformYou are developing a microservices-based application on Google Cloud. Each microservice is responsible for a specific domain and communicates with others using REST APIs. One of the services occasionally requires data from two other microservices to fulfill a request. To ensure resilience and scalability, which approach should you choose for inter-service communication?
- A
Design the service to synchronously call the two other services sequentially and aggregate the results.
- B
Use a messaging system like Pub/Sub to decouple the communication between services.
- C
Implement a distributed transaction system to ensure data consistency across the microservices.
- D
Introduce a service mesh like Istio to manage inter-service communication.
Show answer and explanation
Correct answer: B
Explanation
In a microservices architecture, decoupling communication between services is crucial for achieving resilience and scalability. Google Cloud Pub/Sub is an excellent choice for asynchronous, event-driven communication, as it reduces the dependency between services and improves fault tolerance. While other options address different aspects of microservices, they are not directly aligned with the goal of enhancing scalability and resilience in this scenario.
- A. Incorrect.
This approach creates tight coupling between services and increases latency, which negatively impacts resilience and scalability.
- B. Correct.
Using a messaging system like Pub/Sub enables asynchronous communication, decouples microservices, and enhances scalability and fault tolerance, making it the most suitable approach.
- C. Incorrect.
Distributed transactions can be complex and introduce performance bottlenecks, which contradict the principles of microservices architecture.
- D. Incorrect.
A service mesh like Istio is useful for managing traffic, observability, and security but does not directly solve the problem of decoupling services for resilience and scalability.