Consider a system where multiple microservices communicate internally. Which of the following is the main advantage of using gRPC instead of REST for this internal communication?
Think about how network efficiency and protocol features affect communication speed and resource use.
gRPC uses HTTP/2 which supports multiplexing multiple requests on a single connection, reducing latency and improving throughput compared to REST which typically uses HTTP/1.1. This makes gRPC efficient for internal microservice communication.
You have multiple microservices communicating via gRPC. Which approach best supports dynamic service discovery to handle scaling and failures?
Think about how services can find each other reliably when instances change dynamically.
A centralized service registry allows services to register their current addresses and clients to discover them dynamically. This supports scaling and failure handling better than static configurations or broadcasting.
Your microservice needs to send a continuous stream of updates to clients using gRPC. What is the best way to handle backpressure and avoid overwhelming clients?
Consider how gRPC supports managing message flow between sender and receiver.
gRPC supports flow control in streaming RPCs, allowing clients to control how many messages they can handle. This prevents overwhelming clients and manages backpressure effectively.
Which of the following is a correct tradeoff when choosing gRPC with Protocol Buffers over JSON/HTTP for internal APIs?
Think about message size, speed, and schema requirements.
gRPC uses Protocol Buffers which are compact and fast but require predefined schemas. JSON is human-readable and flexible but larger and slower to parse.
You have 100 microservice instances communicating via gRPC. Each instance sends 50 requests per second to 10 other instances. Each request message is 2KB and response is 3KB. Estimate the total network bandwidth needed for gRPC communication in Mbps.
Calculate total messages per second and multiply by message sizes, then convert bytes to bits and to Mbps.
Total requests per second = 100 instances * 50 requests/sec * 10 targets = 50,000 requests/sec.
Each request + response size = 2KB + 3KB = 5KB = 5 * 1024 bytes = 5120 bytes.
Total bytes per second = 50,000 * 5120 = 256,000,000 bytes/sec.
Convert to bits: 256,000,000 * 8 = 2,048,000,000 bits/sec.
Convert to Mbps: 2,048,000,000 / 1,000,000 = 2048 Mbps, which is much higher than the options given.