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. Deterministic sampling plus durable seen-state at scale.
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. designing offline reads plus a sync queue.
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. Whether you design reliable cross-system sync.
Move from flat to usage-based billing
Reliable usage capture, idempotent aggregation into billing periods, and reconciliation with the provider. accurate, scalable metering and billing. tallying charges synchronously or ignoring duplicates and late events.
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. understanding idempotency.
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. Designing fault-tolerant async workers.
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. Safe-retry design.
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. reliable, retryable pipeline design.
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… understanding delivery guarantees and effects.
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. knowledge of idempotent loads. a naive INSERT that duplicates or a delete-then-insert race.
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. reliability under retries.
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. handling at-least-once delivery. assuming exactly-once.
Cost-effective fault-tolerant batch processing
Spot fleets across types, a durable work queue, idempotent checkpointed tasks, retries. batch architecture and cost-fault trade-offs.
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. server-authoritative state with multi-client sync.
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. modeling a stateful flow with idempotency and concurrency safety.
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. the control-loop model.
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.
Open testing — you’ll join as an early tester.