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 (8 months ago)·1 min read
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
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.