Route Requests to the Nearest Healthy Data Center with Capacity

Quick Overview

Route requests to the nearest healthy data center with free capacity, using explicit geometry, deterministic ties, state updates, and atomic reservation considerations.

Route Requests to the Nearest Healthy Data Center with Capacity

Company: Stripe

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

Implement a router that selects the nearest healthy data center with available capacity for a request location. Support updating data-center state as capacity or health changes. ### Constraints & Assumptions The source does not specify coordinate geometry or command strings. Accept a supplied distance function and model each center with ID, location, health, and nonnegative available capacity. For this practice interface, successful routing reserves one capacity unit; select the lexicographically smallest ID on equal distance. Return no center if none is eligible. These are explicit assumptions to confirm. ### Clarifying Questions to Ask - Are coordinates planar or geographic, and which distance formula is required? - Does routing consume capacity, or only report a candidate? - What tie-breaker and update semantics do the original commands specify? ```hint Filter before ranking An unhealthy or full center must not win merely because it is geographically closest. ``` ### What a Strong Answer Covers - State updates and eligibility filtering before distance comparison. - Deterministic equal-distance behavior and no-candidate handling. - Capacity reservation and the concurrency boundary. ### Follow-up Questions - When would a spatial index help, and how does rapidly changing eligibility complicate it? - How would you atomically reserve capacity under concurrent requests?

Overview: Route requests to the nearest healthy data center with free capacity, using explicit geometry, deterministic ties, state updates, and atomic reservation considerations.

Stripe logo
Stripe
Nov 20, 2026
mediumSoftware EngineerTechnical ScreenCoding & Algorithms
0
0

Implement a router that selects the nearest healthy data center with available capacity for a request location. Support updating data-center state as capacity or health changes.

Constraints & Assumptions

The source does not specify coordinate geometry or command strings. Accept a supplied distance function and model each center with ID, location, health, and nonnegative available capacity. For this practice interface, successful routing reserves one capacity unit; select the lexicographically smallest ID on equal distance. Return no center if none is eligible. These are explicit assumptions to confirm.

Clarifying Questions to Ask Guidance

  • Are coordinates planar or geographic, and which distance formula is required?
  • Does routing consume capacity, or only report a candidate?
  • What tie-breaker and update semantics do the original commands specify?

What a Strong Answer Covers Guidance

  • State updates and eligibility filtering before distance comparison.
  • Deterministic equal-distance behavior and no-candidate handling.
  • Capacity reservation and the concurrency boundary.

Follow-up Questions Guidance

  • When would a spatial index help, and how does rapidly changing eligibility complicate it?
  • How would you atomically reserve capacity under concurrent requests?