Bird
Raised Fist0

How to Present Trade-offs and Justify Design Decisions to Interviewers

HLDmediumInterview freq: high
Choose your preparation mode4 modes available
▶
Request Trace
Step 1/6
API Gateway

Receives client HTTP request

Validates and forwards request to Load Balancer

Protocol:HTTP/REST
BeforeClient request is sent but not yet received by system
AfterAPI Gateway has validated and accepted the request
Load Balancer

Routes request to Write Service instance

Selects healthy Write Service via gRPC

Protocol:gRPC
BeforeAPI Gateway holds validated request
AfterWrite Service instance receives request for processing
Write Service

Processes write and publishes event to Kafka

Transforms request and produces event to Kafka topic

Protocol:Kafka Produce
BeforeWrite Service has request but no event published
AfterEvent durably stored in Kafka Cluster
Kafka Cluster

Delivers event to Cassandra DB consumer

Kafka consumer writes to Cassandra DB

Protocol:Kafka Consume
BeforeEvent is stored in Kafka but not yet processed
AfterData persisted in Cassandra DB
Cassandra DB

Stores data and triggers cache update

Write Service updates Redis cache with new data

Protocol:Redis SET
BeforeData not yet persisted in Cassandra or cached in Redis
AfterData persisted in Cassandra and cached in Redis
Read Service

Reads data from Redis cache

If cache miss, falls back to Cassandra DB

Protocol:Redis GET
BeforeRead Service has read request but no data retrieved
AfterRead Service returns data from Redis or Cassandra
🏗️
Architecture Diagram
Architecture Diagram
┌───────────────┐
│  API Gateway  │
└───────┬───────┘
        │ HTTP/REST
        ▼
┌───────────────┐
│ Load Balancer │
└───────┬───────┘
        │ gRPC
        ▼
┌───────────────┐
│ Write Service │
└───────┬───────┘
        │ Kafka Produce
        ▼
┌───────────────┐
│ Kafka Cluster │
└───────┬───────┘
        │ Kafka Consume
        ▼
┌───────────────┐
│ Cassandra DB  │
└───────┬───────┘
        │ Redis SET
        ▼
┌───────────────┐
│ Redis Cluster │
└───────┬───────┘
        │ Redis GET
        ▼
┌───────────────┐
│ Read Service  │
└───────────────┘

This architecture demonstrates a typical write-read flow with trade-offs. The API Gateway handles client requests and forwards them to a Load Balancer, which distributes load to Write Service instances. The Write Service publishes events to a Kafka Cluster, ensuring durable, ordered event storage that decouples writes from reads. Kafka consumers persist data into Cassandra DB, optimized for high write throughput and availability. To improve read latency, Redis Cluster caches recent data, enabling the Read Service to serve requests quickly. This design balances durability, scalability, and low latency by combining asynchronous event processing with caching, illustrating trade-offs between consistency, availability, and performance.

Primary Focus

✓

Practice

(1/5)
1. In the TLS handshake trace, at step 4 the server sends its certificate chain to the client. What does the client do immediately after receiving this chain at step 5?
easy
A. The client closes the connection if the certificate is expired without any retries
B. The client immediately sends encrypted application data without verification
C. The client requests a new certificate from the server
D. The client verifies the certificate chain against trusted root CAs

Solution

  1. Step 1: Understand client certificate validation

    After receiving the server's certificate chain, the client validates it against its trusted root certificate authorities to ensure authenticity.
  2. Step 2: Eliminate incorrect options

    The client immediately sends encrypted application data without verification is wrong because the client must verify before sending encrypted data. The client requests a new certificate from the server is incorrect; clients do not request certificates from servers. The client closes the connection if the certificate is expired without any retries is partially true but the client may attempt other steps like checking revocation before closing.
  3. Final Answer:

    Option D -> Option D
  4. Quick Check:

    Client verifies certificate chain before proceeding [check]
Hint: Client verifies certificate chain before encrypted data [check]
Common Mistakes:
2. For the product search feature, which architecture is better to support low-latency queries with frequent product updates and why?
medium
A. Use a relational database with full-text indexing updated synchronously on every product change
B. Use a NoSQL document store with secondary indexes for search queries
C. Use a distributed cache with precomputed search results refreshed every hour
D. Use a search engine like Elasticsearch with near real-time indexing and eventual consistency

Solution

  1. Step 1: Evaluate synchronous indexing impact

    Relational DB with synchronous full-text indexing (A) causes high write latency and poor scalability.
  2. Step 2: Compare alternatives

    Elasticsearch (B) supports near real-time indexing, low-latency queries, and scales well with frequent updates. Cache refresh (C) is too stale for frequent updates. NoSQL with secondary indexes (D) lacks efficient full-text search capabilities.
  3. Final Answer:

    Option D -> Option D
  4. Quick Check:

    Elasticsearch balances update frequency and query latency [check]
Hint: Near real-time indexing beats synchronous full-text DB updates [check]
Common Mistakes:
3. For a global API rate limiter with strict per-user limits, which architecture best balances consistency and latency?
medium
A. Use client-side counters with periodic server reconciliation
B. Use a single centralized Redis instance for all counters
C. Use a sharded Redis cluster with consistent hashing per user ID
D. Use a distributed SQL database with strong consistency guarantees

Solution

  1. Step 1: Analyze consistency and latency needs

    Strict per-user limits require consistent counters with low latency.
  2. Step 2: Evaluate architectures

    Centralized Redis (A) is a bottleneck; client-side counters (C) are eventually consistent and unreliable; distributed SQL (D) has high latency. Sharded Redis with consistent hashing (B) balances load and maintains per-user consistency.
  3. Final Answer:

    Option C -> Option C
  4. Quick Check:

    Sharded Redis cluster scales with consistent hashing per user [check]
Hint: Shard counters by user ID for scalable consistency [check]
Common Mistakes:
4. Without the metadata service that tracks access frequency and last access time, what failure occurs in the storage tiering system?
medium
A. Clients cannot read data because metadata is required for decryption keys
B. Data migration workers cannot decide when to move data, causing stale data to remain in expensive hot storage
C. Data blocks are duplicated across all tiers, increasing storage cost
D. Data is immediately archived without validation, causing data loss

Solution

  1. Step 1: Role of metadata service

    Metadata tracks access patterns to trigger tier migration safely without data loss.
  2. Step 2: Consequence of missing metadata

    Without metadata, migration workers may archive data prematurely without validation, causing permanent data loss.
  3. Final Answer:

    Option D -> Option D
  4. Quick Check:

    Missing metadata -> unsafe archiving -> data loss [check]
Hint: Metadata missing -> unsafe archiving -> data loss [check]
Common Mistakes:
5. At 10x traffic scale, which component is most likely to fail first in a latency monitoring system that tracks P50, P95, and P99 latencies, and why?
hard
A. The data storage, because it cannot handle the increased volume of raw latency data
B. The aggregation service, because computing percentiles in real-time requires heavy CPU and memory resources
C. The alerting system, because it cannot process the increased number of alerts generated
D. The client instrumentation, because it cannot send telemetry fast enough

Solution

  1. Step 1: Identify bottleneck in percentile computation

    Computing P50, P95, and P99 latencies in real-time requires sorting or approximation algorithms that are CPU and memory intensive.
  2. Step 2: Why aggregation service fails first

    At 10x scale, the aggregation service faces exponential resource demands, making it the first to fail before storage or alerting.
  3. Final Answer:

    Option B -> Option B
  4. Quick Check:

    Real-time percentile computation scales poorly -> aggregation service fails first [check]
Hint: Percentile computation is CPU-heavy; aggregation fails first [OK]
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