Skip to content

feat(deployment): latency-based multi-region routing for deployment orchestration#851

Merged
temma02 merged 1 commit into
StellerCraft:mainfrom
Manuel1234477:feat/multi-region-deployment-routing
Jun 27, 2026
Merged

feat(deployment): latency-based multi-region routing for deployment orchestration#851
temma02 merged 1 commit into
StellerCraft:mainfrom
Manuel1234477:feat/multi-region-deployment-routing

Conversation

@Manuel1234477

Copy link
Copy Markdown
Contributor

Summary

Adds a region selection service that picks the optimal Vercel deployment region based on measured latency, instead of always targeting a single region.

  • RegionSelectorService (apps/backend/src/services/region-selector.service.ts):
    • Supports regions us-east-1, eu-west-1, ap-southeast-1.
    • Measures user→region latency (per-region health-endpoint probe) and region→Horizon latency (Stellar Horizon endpoint for the chosen network, reusing getNetworkMetadata).
    • Selects the region minimising 0.7 × user_latency + 0.3 × horizon_latency.
    • Caches the selection in Supabase with a 5-minute TTL (region_latency_cache) to avoid re-measuring on every deployment.
    • Fallback to us-east-1 when measurement fails.
  • Pure, exported helpers scoreRegion / selectOptimalRegion keep the algorithm unit-testable; the latency probe is injectable.
  • New region_latency_cache table (supabase/migrations/014_region_latency_cache.sql).

Tests

apps/backend/src/services/region-selector.service.test.ts covers the weighted selection algorithm across latency combinations, the 5-minute cache (hit within TTL, miss when expired), cache writes, and the fallback path.

Run: pnpm --filter @craft/backend test -- region-selector

Closes #757

…nt orchestration

Adds RegionSelectorService which measures user→region and region→Horizon
latency for us-east-1, eu-west-1 and ap-southeast-1, selects the region
minimising 0.7·user + 0.3·horizon, caches the choice in Supabase with a 5-minute
TTL, and falls back to us-east-1 when measurement fails.

Closes StellerCraft#757
@drips-wave

drips-wave Bot commented Jun 26, 2026

Copy link
Copy Markdown

@Manuel1234477 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@temma02 temma02 merged commit 9ac1028 into StellerCraft:main Jun 27, 2026
0 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Multi-Region Deployment Orchestration with Latency-Based Routing Selection

2 participants