---
title: "Data API Routes to Nearest Read Replica"
description: "Supabase's API load balancer now routes read-only Data API (PostgREST) requests to the geographically nearest Postgres read replica."
url: "https://swe.quest/articles/data-api-routes-to-nearest-read-replica-b989a5a10d286212"
canonical: "https://supabase.com/blog/data-api-nearest-read-replica"
source: "Supabase"
published: "2025-04-04"
difficulty: "easy"
kind: "Announcement"
reading_minutes: 2
tags: ["load-balancing","replication","postgres","geospatial"]
---

# Data API Routes to Nearest Read Replica

A post on [Supabase](https://swe.quest/sources/supabase.md), published 2025-04-04, 2 min read, Announcement. Original: [https://supabase.com/blog/data-api-nearest-read-replica](https://supabase.com/blog/data-api-nearest-read-replica)

## Summary

Supabase's API load balancer now routes read-only Data API (PostgREST) requests to the geographically nearest Postgres read replica. It takes the edge datacenter's IATA code from Cloudflare's \`cf.colo\` property, maps replica regions to coordinates, computes Haversine great-circle distance to pick the closest replica, and round-robins when several replicas share a region. Geo-routing applies automatically when using the \`\<project\_ref\>-all.supabase.co\` load balancer endpoint, with Auth, Storage and Realtime support planned.

Written by swe.quest, not by the author.

**Difficulty:** Easy: no special background needed; explains what something is and why it matters

## Topics

- [Load balancing](https://swe.quest/tags/load-balancing.md) (Infrastructure)
- [Replication](https://swe.quest/tags/replication.md) (Distributed systems)
- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Maps & geospatial](https://swe.quest/tags/geospatial.md) (Domains)

## Prerequisites

- database read replicas ([easy posts on Databases](https://swe.quest/tags/databases.md?difficulty=easy))

## Keywords

Supabase, PostgREST, Haversine formula, Cloudflare, read replicas

## Related posts

- [Introducing Read Replicas](https://swe.quest/articles/introducing-read-replicas-3301ec5316ccd33a.md): Supabase · 2023-12-15 · Medium · 6 min read · PostgreSQL, Replication, Scaling
  Supabase now supports Postgres read replicas in 12 regions, up to two per project, for offloading reads and analytics, serving data closer to users, and redundancy.
- [Supavisor 1.0: a scalable connection pooler for Postgres](https://swe.quest/articles/supavisor-1-0-a-scalable-connection-pooler-for-postgres-561015cc29e3cac0.md): Supabase · 2023-12-13 · Medium · 3 min read · PostgreSQL, Elixir & Erlang, Load balancing, Replication
  Supavisor 1.0, Supabase's Elixir-based Postgres connection pooler, is production-ready and adds query load balancing, named prepared statement support in transaction mode, and query cancelation.
- [When to use Read Replicas vs. bigger compute](https://swe.quest/articles/when-to-use-read-replicas-vs-bigger-compute-061db4b923addf0b.md): Supabase · 2026-01-15 · Medium · 12 min read · PostgreSQL, Replication, Scaling, Capacity planning, Cost optimization
  Choosing between vertical scaling and Postgres Read Replicas comes down to diagnosing the bottleneck first, using pg\_stat\_statements, read/write ratio queries, CPU utilization and EXPLAIN ANALYZE.
- [Does your application need local data or faster Postgres?](https://swe.quest/articles/does-your-application-need-local-data-or-faster-postgres-dc8690cbad1e3fc9.md): ClickHouse · 2026-11-03 · Easy · 9 min read · PostgreSQL, Local-first & sync, System design, Replication, AI agents
  Before adding a sync engine or local data copy to speed up an application, check whether the real bottleneck is network-attached storage under managed Postgres.
- [Rethinking read replicas for the lakebase architecture](https://swe.quest/articles/rethinking-read-replicas-for-the-lakebase-architecture-35eaea5162536008.md): Neon · 2026-11-25 · Medium · 15 min read · PostgreSQL, Replication, Storage engines, Cloud platforms, Cost optimization
  Lakebase Postgres implements read replicas as additional read-only computes attached to the same disaggregated storage as the primary, rather than as physical clones with their own volumes.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
