Skip to content

perf: pin database routes to iad1 (search ~6×, views ~3× faster) - #168

Merged
benthecoder merged 2 commits into
mainfrom
neon-region
Oct 28, 2026
Merged

benthecoder merged 2 commits into
mainfrom
neon-region

Conversation

@benthecoder

Copy link
Copy Markdown
Owner

Follow-up to #167. #167 had no effect: its preview still ran in sin1 (x-vercel-id: iad1::sin1) at the same 1.6–2.6s per search. Vercel ignores Next's per-route preferredRegion here. The supported mechanism is regions under functions in vercel.json (per the Vercel docs on configuring function regions).

This removes #167's dead preferredRegion lines and sets regions: ["iad1"] for app/api/search, app/api/thoughts and app/api/tweet.

Plan caveat: Hobby allows a single function region, and a deploy asking for a second fails before the build. If this preview fails for that reason, the fix is to move the whole project's default region to iad1 (Settings → Functions → Function Regions, or "regions": ["iad1"] at the top of vercel.json). Measurements will follow in a comment.

tsc, tests and knip pass.

@vercel

vercel Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
blog Ignored Ignored Preview Oct 28, 2026 3:59pm UTC

@benthecoder

Copy link
Copy Markdown
Owner Author

Measured on this PR's preview deploy (blog-git-neon-region…vercel.app), same queries as production:

query production (sin1) preview (iad1)
hybrid "chinatown" 1,430–1,905ms 316ms
hybrid "learning to code" 1,945–2,014ms 344ms
hybrid "taiwan trip" 1,660–2,139ms 256ms
hybrid "fear of failure" 2,561–2,618ms 308ms
hybrid "quiet sunday mornings" 1,352–1,621ms 300ms
/api/thoughts — 159ms

x-vercel-id is now iad1::iad1, and results are identical. The first request (keyword "miso soup", 782ms) was the cold start. The per-function region was accepted and the deploy succeeded, so the plan allows it. Ready to merge.

@benthecoder benthecoder changed the title perf: actually pin database routes to iad1 [preview] perf: pin database routes to iad1 (search ~6× faster) Oct 28, 2026
@benthecoder

Copy link
Copy Markdown
Owner Author

Added app/api/views/route.ts to the iad1 pin. Measured on a preview, view-count reads went from ~470ms in sin1 to ~140ms in iad1 (warm, with identical counts), so the Upstash database is US-side too. Same change: one more regions: ["iad1"] entry in vercel.json.

@benthecoder benthecoder changed the title perf: pin database routes to iad1 (search ~6× faster) perf: pin database routes to iad1 (search ~6×, views ~3× faster) Oct 28, 2026
@benthecoder
benthecoder merged commit 5cd5945 into main Oct 28, 2026
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.

1 participant