CodeSignal Technical Assessment System Design and Architecture 2 — Questions and Answers
Question 1: A payment service must guarantee that a transaction is processed exactly once even if retries occur. Which pattern best addresses this?
- Optimistic locking with version fields
- Idempotency keys stored server-side (Correct answer)
- Two-phase commit across all services
- Read-your-writes consistency
Correct answer: Idempotency keys stored server-side
Idempotency keys allow clients to retry safely because the server deduplicates requests by key and returns the original result.
Question 2: You need to fan out a single event to 10,000 subscribers with low latency. Which messaging topology is most appropriate?
- Point-to-point queue
- Pub/sub topic with push delivery (Correct answer)
- Request-response RPC
- Polling-based job queue
Correct answer: Pub/sub topic with push delivery
Pub/sub topics push messages to all subscribers simultaneously, making fan-out efficient without sender knowledge of each consumer.
Question 3: Which consistency model allows reads to see stale data but guarantees eventual convergence across replicas?
- Linearizability
- Sequential consistency
- Eventual consistency (Correct answer)
- Strict serializability
Correct answer: Eventual consistency
Eventual consistency permits temporary staleness but guarantees all replicas will converge to the same value given no new updates.
Question 4: A microservice architecture experiences cascading failures when a downstream service is slow. Which pattern prevents this?
- Retry with exponential backoff only
- Circuit breaker (Correct answer)
- Synchronous chaining
- Database connection pooling
Correct answer: Circuit breaker
A circuit breaker trips after repeated failures, stopping calls to the unhealthy service and allowing it time to recover.
Question 5: You are designing a URL shortener expected to handle 10,000 writes/sec. What is the primary bottleneck to address first?
- Application server CPU
- Unique ID generation at scale (Correct answer)
- DNS resolution latency
- TLS handshake overhead
Correct answer: Unique ID generation at scale
At high write rates, generating collision-free short codes becomes the bottleneck; solutions include Snowflake IDs or distributed counters.
Question 6: Which storage engine characteristic makes LSM trees preferable over B-trees for write-heavy workloads?
- Reads are always faster with LSM trees
- LSM trees write sequentially to memory then flush to disk (Correct answer)
- LSM trees require no compaction
- LSM trees store data in sorted order on first write
Correct answer: LSM trees write sequentially to memory then flush to disk
LSM trees batch writes in an in-memory buffer and flush sequentially, converting random writes into sequential I/O which is much faster.
Question 7: A CDN serves static assets globally. A user in Tokyo requests an asset cached in Singapore. What metric describes the extra delay from that geographic distance?
- Throughput degradation
- Network latency (propagation delay) (Correct answer)
- Cache miss penalty
- Bandwidth throttling
Correct answer: Network latency (propagation delay)
Propagation delay is the time signal takes to travel the physical distance between nodes, which is a fundamental latency floor.
A payment service must guarantee that a transaction is processed exactly once even if retries occur.
Which pattern best addresses this?