Scrivio Interview library
LeadershipPrincipal6 min read · updated 13 November 2026

A platform team proposes to offer idempotency as a gateway feature: the gateway stores keys and responses for every POST, so services need no code for it. Some service owners say only the service can know when an operation took effect.

As the senior technical leader, how do you evaluate the proposal, and what do you make the platform's responsibility versus each service's?

A gateway-level idempotency layer is worth having because it cheaply handles the most common case, a client retry after the response was stored, and it can block concurrent duplicates. But it cannot make a service's operation atomic with its idempotency record, so after a crash or timeout it cannot tell whether the operation happened, and it does nothing for retries inside the platform or message redelivery. So the platform should standardise the header, key format, retention, error codes and a shared library or sidecar, while each service owns the transactional record and the business rule, and the decision should be checked against incident data.

Background to this question

Platform teams exist to remove repeated work from product teams, and idempotency looks like a perfect candidate: every service with a POST endpoint needs it, and most implement it slightly differently. The service owners' objection, that only the service knows whether an operation took effect, is also correct. A senior leader's job is to find the boundary where both are right and to decide with evidence rather than opinion. In this answer, we will look at what a gateway can and cannot know, where the failure cases lie, which kinds of duplicates the gateway would never see, how to split responsibilities, and how to use incident data to settle the debate.

1What the Gateway Can Do Well

A gateway sits in front of every service, so it sees every request and response. With a key store, it can implement the visible part of idempotency: when a request arrives with a key it has already seen and a stored response exists, it replays the response without calling the service. When a request arrives while another with the same key is still being forwarded, it can return 409 Conflict. When the same key arrives with a different body, it can return 422.

That covers the most common real case: a mobile client whose connection dropped after the server answered, retrying a few seconds later. Doing it once in the gateway means fifty services get consistent behaviour for free, and new services do not forget it. It is a genuine improvement, and we should say so before discussing its limits.

2Where the Gateway Is Blind

The gateway knows what it sent and what it received, not what happened inside the service. Consider the sequence where the gateway forwards a request, the service commits the order, and then the response is lost because the service pod is killed or the gateway's timeout fires first. The gateway's record for that key says 'in progress' with no response. When the client retries, the gateway has two choices, both bad: forward the request again, and risk a second order, or keep returning 409 forever, and block a legitimate retry for an operation that may never have happened.

The root of the problem is atomicity. Only the service can write its idempotency record in the same transaction as its business change, so that the record and the effect commit together. A separate store in the gateway can never be atomic with the service's database. The gateway can reduce the window, but it cannot close it.

Step throughThe case the gateway cannot resolve
ClientGatewayOrder serviceOrders DB
POST /orders key K
store K: in progress
forward
commit order
response lost: pod killed
504 Gateway Timeout
retry key K
K in progress, no response: forward or refuse?

8 messages in order. Play them, or step through them one at a time.

Only the service knows whether the order was committed.

3Duplicates the Gateway Never Sees

Many duplicate effects never pass through the edge gateway at all. Service-to-service calls retry inside the platform: the checkout service retries a call to the inventory service, perhaps through a mesh. Message consumers receive the same event twice, because Kafka and most brokers deliver at least once. Scheduled jobs rerun after a crash. And calls to external providers, such as a payment gateway, need the provider's own idempotency key.

For all of these, the service itself has to be idempotent in its business logic: a unique constraint on (order_id, line_id), an idempotent consumer that records processed event ids in the same transaction, keys passed to external providers. If teams believe the gateway 'handles idempotency', they may stop building these, and the platform would have made the system less safe.

4A Sensible Split of Responsibilities

So the answer is neither 'gateway does it all' nor 'every team on its own'. The platform owns the standard and the tooling: the header name (Idempotency-Key), key format and maximum length, retention, the meaning of 409 and 422 and their error bodies, metrics and dashboards, and a library (for example a Spring Boot starter) or sidecar that implements the claim-replay-conflict logic against the service's own database. The gateway can still deduplicate replays of completed responses as a fast path, if the service marks which endpoints allow it.

Each service owns the transactional record and the business rule. It decides what counts as the same operation, it writes the record in the same transaction as its change, it builds idempotent consumers, and it passes keys to providers. The library makes that a few lines of configuration instead of a project, which addresses the platform team's real goal: not to centralise for its own sake, but to stop every team reinventing it.

Who owns what
ConcernPlatformService
Header name, key format, error codesdefines and documentsfollows
Retention and metricssets defaults, builds dashboardscan tighten
Claim, replay and conflict logiclibrary or sidecarconfigures per endpoint
Record committed with the business change-owns, same transaction
Idempotent consumers and provider keyspatterns and examplesowns
Fast-path replay at the gatewayoptional, opt-inmarks safe endpoints

5Deciding With Incident Data

Both camps have good arguments, so the tie-breaker is evidence. We take the last year of duplicate-effect incidents, double orders, double payments, duplicate emails, and classify each by cause: client retry after a stored response, concurrent client retries, lost response after commit, internal retry between services, message redelivery, provider retry. For each class we ask whether the gateway layer would have prevented it.

If most incidents were simple client retries, the gateway fast path is good value and should be built, alongside the library. If most came from redelivery and internal retries, as is common in event-driven platforms, the gateway would have prevented few of them, and the investment should go into the shared library and idempotent consumer patterns first. Presenting this table to both teams usually ends the argument, because it replaces 'who is right' with 'what would have helped'.

6Follow-up questions

How do you keep the gateway's cached responses from leaking data between users?

Scope every key by the authenticated principal: the gateway stores and looks up the record under (tenant, user or API client, key), never the bare key, so a different user who sends the same key gets no match. The request hash should include the caller identity as well as the body. Stored responses are encrypted at rest, kept only for the retention window, never replayed for a request whose credentials differ, and excluded for endpoints that return data personalised beyond the caller. Treat it like a cache of sensitive data, with the same reviews.

Would you let teams opt out?

Teams may choose not to use the gateway fast path, but not the standard: the header, error codes and metrics are mandatory for every public write endpoint, so clients see one consistent behaviour across the platform.

7Conclusion

In this answer, we evaluated gateway-level idempotency. It cheaply handles client retries after a stored response and concurrent duplicates, but it cannot be atomic with a service's database, so it cannot resolve a lost response after commit, and it never sees internal retries or message redelivery. We split the work so the platform owns the standard, retention, error codes, metrics and a library or sidecar, while services own the transactional record and business rules, and we used incident data to decide where to invest first.

What to say in the interviewAbout 90 seconds aloud

Open with

I would start by acknowledging what the gateway does well. It sees every request, so it can replay a stored response when a client retries after a lost connection, and return 409 for concurrent duplicates, consistently for every service.

Then, if they want more

That is the most common retry case, and it is cheap. But the service owners have a real point. The gateway's store can never be committed atomically with the service's database.

If the service commits an order and then the response is lost, the gateway only knows the key is in progress, and it cannot tell whether the order exists, so it must either risk a duplicate or block a valid retry.

And many duplicates never pass the gateway at all: internal retries between services, Kafka redelivery, jobs that rerun, calls to payment providers. Services still need idempotent business operations for those.

So my split would be: the platform owns the standard, meaning the header, key format, retention, error codes, metrics, and a library or sidecar that implements the logic against the service's own database. Each service owns the transactional record and the business rule. The gateway can offer an opt-in fast path for replays.

And I would settle the priority with data: classify last year's duplicate incidents by cause and see which ones the gateway would actually have prevented.

About this answer

Last updated
13 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "As the senior technical leader, how do you evaluate the proposal, and what do you make...": https://scrivio-interview-library.netlify.app/architecture/api-design-at-scale/d428ce9a8e/