Lesson 64 of 81
A feature flag read on every single request can't afford a database round trip. Edge Config is a data store built around that one constraint — and it's easy to confuse with the unrelated, deprecated Edge Runtime.
11 min read
Every option explains itself — why the right one is right, and why each wrong one is wrong. Miss one and it comes back later on a spaced-repetition schedule.
This topic is about judgment and practical tradeoffs more than a single right answer — a mock interview is the better way to test yourself on it.
Be interviewed on this →Hints without spoilers, and a plain explanation of why a wrong answer was wrong — answered only from this lesson. Free account, no card.
Sign up freeWhat interviewers actually ask about this, and what a strong answer has to cover.
A strong answer covers
Likely follow-ups
Edge Config (Vercel's implementation) is a small, read-optimized key-value store built for one specific job: answering a config or feature-flag read fast enough that doing it on every single request doesn't noticeably add latency. The trick isn't a faster network call — it's that there's barely a network call at all. The data is replicated out to every edge location ahead of time, so a get() is read from a local copy, not fetched from a database server somewhere and sent back over the wire. A normal database read has a real round trip baked in: open or reuse a connection, send a query, wait for a response, across however many hundred miles sit between the request and the database's region. Edge Config reads are commonly sub-millisecond; a database read over a network is usually tens of milliseconds at best, more under load or cross-region.
That gap only matters when the read sits on a hot path — code that runs on every request, not once per session. A feature flag checked inside proxy.ts to decide whether to show a new layout is a hot-path read: it runs on literally every page view. A user's notification preferences, fetched once when a settings page loads, is not — a normal database query is completely fine there, and reaching for Edge Config would be solving a latency problem that read never had.
// proxy.ts
import { NextResponse, type NextRequest } from "next/server";
import { get } from "@vercel/edge-config";
export async function proxy(request: NextRequest) {
const maintenanceMode = await get<boolean>("maintenanceMode");
if (maintenanceMode && !request.nextUrl.pathname.startsWith("/maintenance")) {
return NextResponse.rewrite(new URL("/maintenance", request.url));
}
}
This runs before every matched request in the app. Swap get("maintenanceMode") for an equivalent database query and you've added a real, measurable connection-plus-round-trip cost to every page load in the app, not just the one request where someone actually flips the flag — the cost is paid by every visitor, to answer a question that changes maybe a few times a year.
"We want to roll out a new nav layout to 10% of users with a flag we can flip instantly, without slowing down every single page load" is the exact scenario Edge Config exists for, and a candidate who reaches for "just add a column to the users table and query it in proxy" is correctly describing a solution that works, while missing that it reintroduces a database round trip into the single hottest code path in the app — the strong answer names the latency tradeoff specifically, not just "use a faster database."