Google Professional Cloud Developer Question 43
Single answerGoogle Cloud PlatformYou are developing a microservices-based application on Google Cloud. The application consists of multiple services that need to communicate with each other. You want to optimize the performance of internal service-to-service communication while ensuring low latency and efficient payload serialization. Which communication protocol should you choose and why?
- A
HTTP REST, because it provides human-readable data formats like JSON and is widely used.
- B
gRPC, because it uses HTTP/2, supports streaming, and offers efficient binary serialization.
- C
HTTP REST, because it supports complex operations and is optimized for low latency.
- D
gRPC, because it does not require a schema definition, making it more flexible for service communication.
Show answer and explanation
Correct answer: B
Explanation
gRPC is the preferred choice for high-performance internal service-to-service communication in microservices architecture. It leverages HTTP/2 for low latency and efficient communication, supports streaming, and uses Protocol Buffers for compact binary serialization. This makes it more efficient than HTTP REST, which relies on text-based formats such as JSON and does not provide the same level of performance optimization.
- A. Incorrect.
HTTP REST is human-readable and widely used, but it is not optimized for low latency or efficient binary serialization. JSON, typically used with REST, is less efficient than gRPC's binary format.
- B. Correct.
gRPC is designed for high-performance internal service-to-service communication. It uses HTTP/2, which supports multiplexing and streaming, and serializes payloads in a compact and efficient binary format using Protocol Buffers (Protobuf). This makes it ideal for low-latency scenarios.
- C. Incorrect.
While HTTP REST supports complex operations, it is not inherently optimized for low latency. It relies on text-based formats like JSON or XML, which are less efficient than gRPC's binary serialization.
- D. Incorrect.
gRPC requires a schema definition in Protocol Buffers (Protobuf) to ensure efficient communication. This makes it less flexible in terms of schema modifications compared to schema-less approaches.