Bird
Raised Fist0

gRPC for Internal Service Communication - Protocol Buffers, Streaming

HLDmediumInterview freq: medium
Choose your preparation mode4 modes available
▶
Request Trace
Step 1/5
Service Discovery (Consul)

Resolves service address

Client queries Consul to find available gRPC server endpoints

Protocol:DNS/gRPC
BeforeClient does not know gRPC server addresses
AfterClient obtains list of healthy gRPC server addresses
gRPC Load Balancer

Selects target server

Load balancer picks a server from the pool based on health and load

Protocol:gRPC
BeforeMultiple gRPC servers available, no request assigned
AfterRequest assigned to one gRPC server instance
AuthN & AuthZ Middleware

Validates client token

Middleware checks token validity and permissions before forwarding

Protocol:gRPC
BeforeRequest received with client token
AfterRequest authorized or rejected based on token
gRPC Server Pool

Processes request

Server decodes request using Protocol Buffers and executes logic

Protocol:gRPC with Protocol Buffers
BeforeAuthorized request with serialized payload
AfterRequest processed, response prepared
Protocol Buffers

Serializes response

Response data serialized into Protocol Buffers format for transmission

Protocol:Protocol Buffers
BeforeResponse data in memory objects
AfterResponse serialized for network transmission
🏗️
Architecture Diagram
Architecture Diagram
┌───────────────────────────────┐
│ Service Discovery (Consul)    │
│  - Registers & locates servers│
└───────────────┬───────────────┘
                │ DNS/gRPC
                ▼
┌───────────────────────────────┐
│ gRPC Load Balancer            │
│  - Balances requests to server│
└───────────────┬───────────────┘
                │ gRPC
                ▼
┌───────────────────────────────┐
│ AuthN & AuthZ Middleware      │
│  - Validates tokens & perms   │
└───────────────┬───────────────┘
                │ gRPC
                ▼
┌───────────────────────────────┐
│ gRPC Server Pool              │
│  - Processes requests         │
│  - Uses Protocol Buffers      │
└───────────────┬───────────────┘
                │ Protobuf
                ▼
┌───────────────────────────────┐
│ Protocol Buffers              │
│  - Serializes/deserializes    │
│    messages                  │
└───────────────────────────────┘

This architecture illustrates internal service communication using gRPC with Protocol Buffers. Service Discovery via Consul enables clients to locate healthy gRPC servers dynamically. The gRPC Load Balancer distributes requests evenly to prevent overload. Incoming requests pass through Authentication & Authorization Middleware to ensure security before reaching the gRPC Server Pool. Servers decode requests and encode responses using Protocol Buffers, enabling efficient, compact serialization. This design supports streaming and high-performance RPC calls with strong type safety and security enforcement.

Primary Focus

✓

Practice

(1/5)
1. In the vector database request flow, at Step 4 the ANN Search Worker queries the HNSW index with a new vector. What state does the worker observe if the index is currently rebuilding due to a recent bulk insert?
easy
A. The worker returns stale search results from the previous index snapshot
B. The worker blocks until the rebuild completes before returning results
C. The worker returns an empty result set indicating no neighbors found
D. The worker queries a fallback brute-force scan of all vectors

Solution

  1. Step 1: Understand HNSW index rebuild behavior

    HNSW index rebuilds asynchronously; during rebuild, queries use the last consistent snapshot.
  2. Step 2: Analyze worker behavior at Step 4

    The ANN Search Worker returns results from the previous stable index snapshot, so stale but consistent results are served.
  3. Final Answer:

    Option A -> Option A
  4. Quick Check:

    HNSW queries serve last snapshot during rebuild, avoiding blocking [check]
Hint: HNSW queries serve last snapshot during rebuild, no blocking [check]
Common Mistakes:
2. A Q&A platform needs to handle 1 million new questions and answers per day, ensuring that user feeds update with minimal latency and high availability. Which component is best suited to decouple write-heavy ingestion from real-time feed generation?
easy
A. Use a relational database with immediate synchronous writes for feed updates
B. Use a distributed message queue like Kafka to buffer writes before processing
C. Use a cache-only system like Redis without persistence for feed data
D. Use direct HTTP calls from write API to feed service for immediate consistency

Solution

  1. Step 1: Identify ingestion and feed update decoupling

    Direct synchronous writes (A, D) block user requests and reduce availability under high load. Redis without persistence (C) risks data loss on failure.
  2. Step 2: Evaluate Kafka's role

    Kafka buffers high write throughput, supports partitioning for scalability, and decouples ingestion from feed generation, ensuring durability and replayability.
  3. Final Answer:

    Option B -> Option B
  4. Quick Check:

    Kafka buffers high write load, enabling asynchronous feed updates [check]
Hint: Buffer writes with durable queue to decouple ingestion [check]
Common Mistakes:
3. In a GraphQL request flow, at step 3 the resolver fetches data from multiple microservices. What happens if one microservice responds slowly at this step?
easy
A. The GraphQL server returns an error immediately without any data
B. Partial data from fast microservices is returned immediately, slow ones are omitted
C. The entire GraphQL query waits until all microservices respond before returning data
D. The GraphQL server caches the slow microservice response and returns stale data

Solution

  1. Step 1: Understand GraphQL resolver behavior

    GraphQL resolvers aggregate data from all sources before responding to the client.
  2. Step 2: Trace slow microservice impact at step 3

    If one microservice is slow, the entire query waits, causing increased latency.
  3. Final Answer:

    Option C -> Option C
  4. Quick Check:

    GraphQL waits for all resolvers before responding [check]
Hint: GraphQL waits for all resolvers before response [check]
Common Mistakes:
4. In a system using a NoSQL key-value store with TTL for session data, at step 4 the Session Manager checks the TTL of a session key. What happens if the TTL has expired?
easy
A. The Session Manager queues the session for manual review
B. The Session Manager treats the session as invalid and prompts re-authentication
C. The Session Manager returns stale session data from a backup store
D. The Session Manager extends the TTL automatically to keep the session alive

Solution

  1. Step 1: Understand TTL behavior in NoSQL key-value stores

    TTL expiration means the key is deleted or inaccessible, so session data is invalid.
  2. Step 2: Trace Session Manager's response to expired TTL

    Session Manager cannot extend TTL automatically; queuing for manual review is a fallback for expired sessions.
  3. Final Answer:

    Option A -> Option A
  4. Quick Check:

    Expired TTL -> session queued for review [check]
Hint: Expired TTL means session invalid, no auto extension [check]
Common Mistakes:
5. For a distributed database with high write throughput and large keyspace, which approach to Bloom filter design best balances memory usage and false positive rate?
medium
A. Use a single global Bloom filter for all keys to minimize memory overhead
B. Use partitioned Bloom filters per data shard to localize false positives and reduce memory per filter
C. Use counting Bloom filters everywhere to allow deletions despite higher memory cost
D. Use a cache of recently accessed keys instead of Bloom filters to reduce false positives

Solution

  1. Step 1: Analyze memory and false positive trade-offs

    A single global Bloom filter grows large and has higher false positive rates due to keyspace size; partitioning per shard reduces filter size and localizes false positives.
  2. Step 2: Evaluate alternatives

    Counting Bloom filters allow deletions but consume more memory, which is costly at large scale; caching recent keys does not guarantee absence and can miss cold keys.
  3. Final Answer:

    Option B -> Option B
  4. Quick Check:

    Partitioned Bloom filters balance memory and false positives at scale [check]
Hint: Partition filters localize false positives, save memory [check]
Common Mistakes:
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard