Database / Google Spanner Database Interview questions
How can you optimize a multi-region Spanner configuration for latency?
Multi-region latency optimization mostly comes down to controlling where reads and writes physically go relative to the leader region.
- Place the app close to the leader region for write-heavy services, since every write ultimately routes through the leader replicas of the split it touches.
- Use directed reads to pin read traffic to the nearest replica type/region instead of always hitting the leader.
- Use bounded or exact staleness reads where slightly older data is acceptable, letting Spanner serve from the closest replica rather than waiting on leader confirmation.
- Choose an instance configuration whose regions match your user base - a poorly chosen triad of regions can add unnecessary hops for both quorum writes and reads.
- Split read-heavy and write-heavy access patterns across services so read replicas absorb load without adding write latency.
Because write latency is bounded by the quorum round trip among leader-region replicas, no amount of client-side caching fixes a poorly chosen region topology - the fix has to happen at the instance configuration and access-pattern level.
More Related questions...