Idempotency
26 bites tagged Idempotency: interview questions with model answers, and 60-second explainers.
Sampling 5% of users for a one-time survey
Hash user ID for the 5% gate, persist a 'shown' flag, race-safe single display.
Offline data persistence and mutation queue
Persist reads to local storage, store mutations in a durable queue with client ids and status, drain and reconcile on reconnect via NetInfo.
Event-driven sync between billing and CRM
Billing emits a tier-changed event via outbox to a broker, CRM consumes idempotently with retries and DLQ.
Move from flat to usage-based billing
Reliable usage capture, idempotent aggregation into billing periods, and reconciliation with the provider.
Idempotency: PUT vs POST in REST
Idempotent means repeated identical requests leave the same server state; PUT is idempotent, POST is not. Use PUT to overwrite a resource at a known URL.
Reliability patterns for queue-based job processing?
Retries with backoff and jitter for transient faults, dead-letter queues plus a poison-message limit, idempotent handlers and visibility timeouts.
Idempotency in infrastructure provisioning scripts
Idempotency means repeated runs converge to one end state; achieve it via desired-state reconciliation or idempotency keys with read-before-write.
Why design ML pipeline steps to be idempotent?
Re-running a step with the same input yields the same result and no duplicate side effects; enables safe retries and backfills.
Exactly-once semantics in stream processing
Exactly-once means each event affects state once despite retries, it is hard because of failures between processing and committing, and you achieve it via idempotency or atomic…
Design a SQL upsert from a staging table
Define a stable key, use MERGE or INSERT ON CONFLICT, dedupe the staging set first, run in a transaction.
Idempotency in data ingestion pipelines
Idempotency means re-running a step yields the same result with no duplicates; it matters because retries and at-least-once delivery are inevitable; achieve it with deduplication keys or upserts.
Idempotency in event-driven systems
Idempotency means repeated processing yields the same end state; it matters because messages get redelivered; achieve it with idempotency keys and conditional writes.
Cost-effective fault-tolerant batch processing
Spot fleets across types, a durable work queue, idempotent checkpointed tasks, retries.
Cross-platform stateful onboarding sync
Store onboarding state server-side keyed to the user, expose idempotent step-completion APIs, and push updates to other clients.
Design a referral feature's lifecycle and races
A referral entity with explicit states, a unique constraint on the invited user, and atomic transactions plus idempotency to prevent double credits.
The reconciliation loop in an Operator
Reconcile compares desired spec to observed state and converges them, idempotently; triggered by resource changes, watched dependents, and periodic resync.
React Native Offline Sync Strategies
React Native offline sync writes to local storage first, then reconciles with the server later. It keeps forms and messages working offline. The footgun is non-idempotent mutations replayed, creating duplicates or overwriting fresh data.
Design a referral system: data models, APIs, attribution, self-referral prevention
Tests data modeling with fraud guardrails and idempotent rewards. Cover: Users with nullable referred_by, ReferralEvents state table, async ledger attribution, and device-fingerprint self-referral blocks. Red flag: bare integer credit with no audit trail.
Design a variable daily-login reward system with anti-gaming controls
Tests server-side reward probabilities and idempotency in distributed systems. Strong answers cover: configurable weights, idempotent tokens with DB unique constraints, rolling windows, and server-side grants.
What is data pipeline idempotency and how do you design for it?
This tests resilient pipeline design under failure. A strong answer defines idempotency as identical output on repeated runs, highlights safe retries and partial failure recovery, and proposes idempotency keys with atomic writes for daily API loads.
Design an automated 3-email onboarding sequence with early exit
Tests distributed state management and reliable delayed execution. A good design uses an idempotent state field, scheduled jobs with at-least-once delivery, and an event handler to suppress sends on conversion.
How would you design an idempotent order confirmation email sender?
Tests preventing duplicate side effects in distributed systems. Strong answers use deduplication keys, idempotency windows, and distinguish client retries from broker redelivery. Red flag: using a read-before-write check without unique constraints or TTLs.
How would you architect personalized email and coupon delivery at scale?
This tests decoupled rendering and atomic coupon reservation. A strong answer uses template rendering, atomic coupon reservation, an idempotent queue, and batched ESP delivery. Red flag: generating coupons during SMTP without reservation risks overspend.
How do duplicate events bias COUNT(*) and daily login reports?
Tests idempotency in streaming analytics. COUNT(*) overcounts; fix with unique event ID dedup via idempotent writes or COUNT(DISTINCT id), plus daily partition reconciliation. Red flag: SELECT DISTINCT * without a stable key or no reporting safeguard.
Get Idempotency bites daily.
Five a day, five minutes, offline. With quizzes so it sticks.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.