Three seconds down to 200 milliseconds, and not one line of the slow code got any faster.
The endpoint returned shipping options for a cart. It called several carriers for live rates, one after another, inside the request. Each integration was fine on its own. The response time was the sum of the worst day every provider was having.
The contract changed. The code path stayed where it was.
A rate is not a fact you have to fetch: it is a quote with a validity window. So the quotes moved out of the request, computed on a schedule and on cart changes, stored together with the inputs they were derived from (origin, destination, weight bracket, service level), and served from storage. The request became a lookup.
The calls that still had to be live got a budget. Hard per-carrier timeout, run concurrently, and whoever misses the window is simply absent from the options list instead of holding the whole response hostage. One missing carrier is a much smaller problem than a three-second checkout.
The part that is easy to skip: you need an explicit rule for stale. A quote served past its window has to be refreshed or marked, because the price you show is the price you are expected to honour when the label is actually bought.
My take: most slow endpoints in commerce backends are not slow. They are synchronous aggregation of other people's latency, and you fix them by deciding what the response is allowed to not know yet.
The line you draw there, cached quotes with a validity window or blocking on live rates, is the decision I'd actually argue about...