Database / Google Spanner Database Interview questions
How does directed reads improve read latency in multi-region Spanner?
By default, some read paths in a multi-region instance can end up routed toward the leader region even when a closer replica could have served them, because the client isn't explicitly telling Spanner where it prefers to read from. Directed reads let the client specify a preferred replica type (read-write or read-only) and a preferred region or set of regions for a given request.
// Client option example (conceptual) options.directedReadOptions = { includeReplicas: { replicaSelections: [{ location: "us-east4", type: "READ_ONLY" }] } };
With that hint, Spanner routes the read to a nearby read-only replica instead of the leader whenever the request's consistency requirements (like bounded staleness) allow it, cutting the network hop that would otherwise cross to a distant leader region. This is most valuable for read-heavy services with a geographically distributed user base, where consistently steering reads to the nearest healthy replica meaningfully reduces tail latency without changing the transaction's correctness guarantees.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
