Description
All deployments currently target a single Vercel region. Implement a region selection service that picks the optimal Vercel deployment region based on the user's IP geolocation and measured Stellar Horizon endpoint latency for the chosen network.
Requirements and Context
- Support regions: us-east-1, eu-west-1, ap-southeast-1
- Select region that minimizes: 0.7 × user_latency + 0.3 × horizon_latency
- Cache region selection for 5 minutes to avoid re-measurement on every deployment
- Fallback: if region measurement fails, default to us-east-1
Suggested Execution
Branch: feat/multi-region-deployment-routing
Implement Changes
- Create
region-selector.service.ts in apps/backend/src/services/
- Add latency measurement by pinging each region's health endpoint
- Cache results in Supabase with a 5-minute TTL
- Add unit tests for region selection algorithm with mocked latency values
Test and Commit
Run pnpm test -- region-selector and confirm optimal region is selected for various latency combinations.
Example Commit Message
feat(deployment): add latency-based multi-region routing for deployment orchestration
Co-authored-by: <your-name>
Guidelines
- Branch off
main, keep PRs focused on one issue
- All new code must include unit or integration tests
- Ensure
pnpm lint and pnpm typecheck pass before review
- Link this issue in your PR description
- Request review from at least one maintainer before merging
Description
All deployments currently target a single Vercel region. Implement a region selection service that picks the optimal Vercel deployment region based on the user's IP geolocation and measured Stellar Horizon endpoint latency for the chosen network.
Requirements and Context
Suggested Execution
Branch:
feat/multi-region-deployment-routingImplement Changes
region-selector.service.tsinapps/backend/src/services/Test and Commit
Run
pnpm test -- region-selectorand confirm optimal region is selected for various latency combinations.Example Commit Message
Guidelines
main, keep PRs focused on one issuepnpm lintandpnpm typecheckpass before review