0
0
HLDsystem_design~20 mins

Idempotency for safe retries in HLD - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Idempotency Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Idempotency in API Design

Which statement best describes the purpose of idempotency in API requests?

AEnsures that multiple identical requests have the same effect as a single request.
BGuarantees that every request is processed exactly once without any retries.
CAllows requests to be processed in any order without affecting the outcome.
DPrevents any request from being retried automatically by clients.
Attempts:
2 left
💡 Hint

Think about what happens when a client sends the same request multiple times due to network issues.

Architecture
intermediate
2:30remaining
Designing Idempotent Payment API

You are designing a payment API that must support safe retries. Which design choice best supports idempotency?

AReject any repeated payment requests from the same client IP address within a short time window.
BProcess every payment request immediately without checking for duplicates to ensure speed.
CRequire clients to send a unique transaction ID with each payment request and store processed IDs to avoid duplicates.
DAllow clients to retry without any unique identifiers and rely on server timestamps to detect duplicates.
Attempts:
2 left
💡 Hint

Consider how the server can recognize repeated requests safely.

scaling
advanced
3:00remaining
Scaling Idempotency Key Storage

Your system uses idempotency keys to avoid duplicate processing. As traffic grows, what is the best approach to scale idempotency key storage?

AUse a distributed cache with expiration to store idempotency keys and their results for a limited time.
BKeep idempotency keys only in application memory to reduce latency, without persistence.
CStore all idempotency keys indefinitely in a single relational database table without indexing.
DRequire clients to resend idempotency keys if the server loses them due to scaling.
Attempts:
2 left
💡 Hint

Think about balancing fast access and storage limits as traffic increases.

tradeoff
advanced
2:30remaining
Tradeoffs in Idempotency Key Expiration

What is the main tradeoff when setting a short expiration time for stored idempotency keys?

AShort expiration increases storage needs and prevents any duplicate processing.
BShort expiration reduces storage but risks processing duplicates if retries happen after expiration.
CShort expiration guarantees no duplicates but increases latency for all requests.
DShort expiration allows clients to reuse keys indefinitely without server checks.
Attempts:
2 left
💡 Hint

Consider what happens if a retry arrives after the key is removed.

estimation
expert
3:00remaining
Estimating Idempotency Key Storage Capacity

Your API receives 10,000 requests per second, each with a unique idempotency key stored for 24 hours. Each key and result entry uses 1 KB of storage. What is the approximate storage needed to hold all keys for 24 hours?

A8640 GB
B86.4 GB
C8.64 TB
D864 GB
Attempts:
2 left
💡 Hint

Calculate total requests in 24 hours and multiply by storage per key.