Scrivio Interview library
ScenarioAdvanced6 min read · updated 13 November 2026

To cut costs, a pricing service was moved to a second region while its Redis stayed in the first, about 45 ms away. Each request makes 8 sequential Redis calls, and p99 rose from 12 ms to over 380 ms.

What do you change in the short term and in the design, and how do you decide whether Redis should move?

Eight sequential calls across a 45 ms link cost 360 ms before any work happens, so the fix is fewer round trips or less distance, not a faster Redis. In the short term we collapse the eight calls into one pipeline, MGET or Lua script so a request pays one round trip. In the design we bring the data back near the code, with a regional Redis or by moving the service, add a short local cache where staleness is acceptable, and decide with a latency budget, the consistency needs of each key and the real cost of each option.

Why this question is asked

Moving a service to a cheaper region looks like a pure infrastructure change, but it quietly changes the physics of every call the service makes. This is a common real-world incident and a good interview question, because it tests whether we reason from numbers or reach for tuning knobs. In this answer, we will work out why p99 jumped, fix it quickly by cutting round trips, then look at the design options for keeping data close to code, and finally set out how we would decide whether Redis itself should move.

1Why p99 Went From 12 ms to 380 ms

A round trip is the time for a request to reach a server and the reply to come back. In one region it is well under a millisecond. Between regions it is set by distance and the speed of light in fibre, here about 45 ms, and no Redis setting can change it.

The pricing service makes eight Redis calls one after another, each waiting for the previous reply. So every request now carries 8 x 45 ms = 360 ms of pure waiting, plus the 12 ms it used to take. That is almost exactly the 380 ms we see. Notice that Redis CPU, memory and command latency are all unchanged. Scaling Redis up, adding replicas in the old region or tuning the connection pool would change nothing, because the cost is in the number of trips across the link.

Step throughOne request before the fix
Pricing serviceRedis (45 ms away)
GET price:sku
reply after 45 ms
HGET promo:sku
reply after 45 ms
... six more calls, one at a time
total about 360 ms of waiting

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

Each call waits for the previous reply, so the link latency is paid eight times.

2Short Term: One Round Trip per Request

The quickest win is to stop paying the link eight times. We sort the eight calls into two groups. Independent calls, where no call needs another's result, go together into one pipeline, or into one MGET or HMGET when they are simple reads. Dependent calls, where the second key is built from the first reply, cannot be pipelined, so we move that logic to the server in a Lua script or a Redis function, which runs all the steps in one call.

SQL
-- before: 8 sequential calls, about 8 x 45 = 360 ms
-- after: one script call, about 45 ms
local sku = ARGV[1]
local price = redis.call('GET', 'price:' .. sku)
local promo = redis.call('HGET', 'promo:' .. sku, 'active') -- depends on nothing
local tier = redis.call('HGET', 'tier:' .. ARGV[2], 'level') -- customer tier
local rule = redis.call('GET', 'rule:' .. (tier or 'default')) -- depends on tier
return {price, promo, tier, rule}

One caution: a script that builds key names inside itself, as this one does, works on a single Redis node but breaks in Redis Cluster, where every key must be passed in KEYS and live in the same slot. For a cluster we pass the keys explicitly with a hash tag such as {sku123}, or split the script per slot and pipeline the parts. With this change the request pays about 45 ms instead of 360 ms. That is still far worse than 12 ms, which is why this is the short-term step, not the end.

3Design: Keep Data Near the Code

The lasting fix is to make cross-region Redis calls the exception. There are three realistic options. We can run a Redis in the service's new region, filled either by replication from the primary region or by the owning service publishing change events that a small consumer writes into the regional copy. We can move the pricing service back next to its data and accept the higher compute bill. Or we can do both for different keys: hot reference data such as price lists and rules is replicated locally, while data that must be exact stays in the primary region and is read in one batched call.

On top of that, where a few seconds of staleness is acceptable, an in-process cache such as Caffeine with a TTL of 5 to 30 seconds, or with invalidation messages, removes most calls entirely. Price lists that change a few times a day are a perfect fit: a local hit costs microseconds.

Step throughWhere each kind of key should be read
  1. In-process cachePrice lists, rules, flags: microseconds, seconds of staleness
  2. Regional Redis replicaRead-mostly data copied from the primary region
  3. Primary-region RedisExact data such as stock reservations, one batched call
  4. Durable storeSource of truth that refills everything above

4 layers, from the top down. Step through them one at a time.

4Deciding Whether Redis Should Move

We decide with numbers, not taste. First the latency budget: if the pricing endpoint must answer in 50 ms at p99, a 45 ms link leaves no room even for one call, so either the data comes local or the service goes back. Second, the consistency needs of each key: reference data can be a little stale, while a stock reservation or a spend limit may need to read the primary's latest value. Third, cost: a regional Redis costs money, and so does cross-region traffic, which cloud providers bill per gigabyte; set those against the saving that motivated the move. Fourth, failure behaviour: if the link between regions degrades, a service that depends on remote Redis fails with it, while a local copy keeps serving.

Often the honest answer is that the move saved less than the latency costs, and the service should go back until its data can follow it. Saying that clearly is part of a senior answer.

5Follow-up questions

Which of the eight calls would you never cache locally?

Anything where a stale value causes a wrong decision that matters: a stock reservation counter, a per-customer spend or credit limit, a rate-limit counter, or a lock. Those values change on every request from many instances, so a local copy is wrong almost immediately, and acting on it can oversell or overspend. Price lists, promotion rules and feature flags are the opposite and are the best candidates.

Would adding more connections in the pool help?

Only with throughput, not with the latency of one request. Each request still waits for its eight calls in sequence. More connections let more requests wait at the same time; they do not shorten the wait.

Why not just use a Redis replica in the new region for everything?

Replication is asynchronous, so a replica can lag behind the primary, and writes still have to cross the link. For read-mostly data it is a good fit; for keys that are written on every request it simply moves the round trip from reads to writes.

6Conclusion

In this answer, we saw that the p99 jump came from multiplying a 45 ms link by eight sequential calls, which no Redis tuning can fix. Short term, we merge independent calls into one pipeline or MGET and dependent ones into a script, so each request pays one round trip. In the design we keep data near the code with a regional copy, a local cache for data that may be slightly stale, or by moving the service back, and we decide by latency budget, consistency per key, cost and failure behaviour.

What to say in the interviewAbout 80 seconds aloud

Open with

The first thing I would do is the arithmetic: eight sequential calls at 45 ms is 360 ms of waiting, which matches the new p99, so Redis is not slow, the distance is multiplied.

Then, if they want more

Short term, I would cut each request to one round trip. Independent reads go into one pipeline or an MGET, and the calls that depend on each other go into a Lua script or a Redis function, keeping the keys in one slot if we are on a cluster. That brings us to roughly 45 ms.

For the design I would make cross-region calls the exception. Read-mostly data such as price lists and rules gets copied to a Redis in the service's region, through replication or through change events from the owning service, and on top of that an in-process cache with a short TTL removes most calls.

Data that must be exact, like reservations or limits, stays in the primary region with one batched call, or the service moves back. To decide, I would look at the latency budget for the endpoint, which keys can be stale, the cost of a regional Redis plus cross-region traffic against the savings, and what happens when the link degrades.

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 documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Redis documentation
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 "What do you change in the short term and in the design, and how do you decide whether...": https://scrivio-interview-library.netlify.app/databases/redis-internals/b4a406cedd/