IntermediateTECHNICAL
Describe how you would design and implement idempotent APIs for a payment-processing endpoint that might receive duplicate requests due to client retries or network issues. What specific techniques and data models would you use to guarantee correctness?
Backend Developer
General

Sample Answer

For a payment API (e.g., POST /payments), I design idempotency around a client-provided Idempotency-Key. The request includes this key plus stable parameters (amount, currency, payment_method_id). On the backend (e.g., Kotlin + Spring Boot, PostgreSQL), I persist an Idempotency table: {idempotency_key PK, request_hash, payment_id, status, response_body, created_at, ttl}. On each call, I start a serializable or repeatable-read transaction, upsert the idempotency row with a unique constraint on idempotency_key. If the key exists, I verify the request_hash and instantly return the stored response, ensuring duplicates can’t create multiple charges. The payment record also has a unique business key (e.g., external_reference_id) to guard against logic bugs. I set a 24–48h TTL and index on (idempotency_key, created_at) to keep lookups O(log N) while controlling storage growth.

Keywords

Use client-provided Idempotency-Key with stable request parametersStore idempotency records with unique constraint and request hash in PostgreSQLWrap operations in a DB transaction with strict isolation to prevent double chargesReturn cached response on duplicate keys and enforce TTL + indexing for scale
Related Questions

Based on your hydrology and irrigation engineering background, explain how you would estimate the irrigation water requirement for a kharif crop in a semi-arid region of Gujarat. Walk me through each step: from reference evapotranspiration estimation, crop coefficient selection, effective rainfall calculation, to arriving at canal discharge for a given command area.

IntermediateTECHNICAL

In your civil engineering studies, what specific design coursework or project work did you complete related to irrigation channels or canals (e.g., design of lined/unlined canals, distributaries, minors)? Describe one such design in detail, including how you determined discharge, permissible velocity, section dimensions, and lining choice for Gujarat-type soil and climate conditions.

IntermediateTECHNICAL

Walk me through a recent multi-channel digital marketing campaign you managed end-to-end. How did you set objectives, choose channels, allocate budget, and measure success?

IntermediateBEHAVIORAL

In your resume you note improving or optimizing [a process, KPI, or metric]. What specific baseline metrics did you start from, what steps did you personally take, and how did you verify that the improvement was due to your changes rather than external factors?

IntermediatePROBLEM_SOLVING

On your resume you mention working on a cross-functional project (e.g., involving multiple teams or stakeholders). Describe a situation from that project where priorities conflicted—how did you navigate the trade-offs and what was the final outcome?

IntermediateSITUATIONAL