All jobs / Solutions / cloud architect / Application Architecture
Solutions / cloud architect interview question · 1–3 years
A client retries a “create payment” request after a timeout. How does the design stop a double charge?
The strongest answer
The client sends an idempotency key; the server stores the result under that key and returns the same response on a repeat, so retries are safe by design
Why it works
Exactly. Key on the request, result stored, replay returns the original. Retries become harmless.
What a good answer covers
- Client supplies an idempotency key.
- Server stores the result by key.
- Replay returns the same answer.
- Retries are a given; design for them.
Answers that fall short
- Close, but not the strongest: Tell clients never to retry payment requests
Networks retry whether you ask them to or not; the server has to be safe. - Weak: Check whether an identical payment was created in the last minute
Two legitimate identical payments within a minute exist; heuristics guess, keys know. - Red flag: Return an error on every retry so the user starts again
Starting again is exactly how the second charge gets made.
Who gets asked this
More Application Architecture questions
- How do you version a public API so you can change it without breaking customers?
- Two services both need customer data. Who owns it, and how does the other get it?
- How do you keep a monolith modular enough that you could split it into services later?
- Booking a trip touches flights, hotel and payment services. How do you keep them consistent?
- How do you replace a large legacy system without a big-bang cut-over?
- When does separating read and write models earn its complexity, and when does it not?
- A team proposes event sourcing for the whole platform. What do you check before agreeing?
- How do you decide where one service ends and another begins?