Speed up API endpoints by making database and server region closer

Improve API response times by positioning the database and server closer in proximity.

Natt Nguyen·April 14, 2024 (6 months ago)·1 min read

#vercel
#supabase
#infrastructure
#server
#database
Speed up API endpoints by making database and server region closer

While I was watching Theo's Modern React Tutorial video(excellent video btw, I highly suggest watching), I didn't realize I can improve my API response times by going into Vercel's project settings and changing the region to be closer to my database region. I am not using edge compute so doing this would improve the API response times.

Originally, Vercel's Serverless Functions was set the "Washington, D.C., USA (East) – iad1" and my Supabase Postgres "West US (North California) (us-west-1)". The distance is across the United States. There isn't a way to change the region on Supabase but I can change it on Vercel (in a project, under Settings => Functions => Function Region).

Vercel's project settings

Vercel's project settings

Supabase's project settings

Supabase's project settings

By changing Vercel's setting from USA East to USA West, the distance travelled is shorten from across the United States to across state. That was an easy optimization.

Subscribe to my blog

I'd love to share my love for design, engineering, and thinking with you when my new articles are published.

You can unsubscribe at any time, no hard feelings.