Next.js & App Router (50 Qs)•Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)
Optimizing Edge Runtime vs. Node.js Runtime (`export const runtime = 'edge' | 'nodejs'`).
senior LevelSystem Design
In Simple Words:
- Node.js Runtime (Default):
- Full access to Node.js APIs (
fs,net,crypto, native C++ binaries like Sharp). - Can connect to standard database pools. Cold starts: 200-800ms.
- Full access to Node.js APIs (
- Edge Runtime (V8 Isolates):
- Runs on lightweight Web Workers / V8 isolates across 300+ global edge locations.
- Sub-10ms cold starts.
- Limitations: No
fs, noeval, 4MB memory limit, and cannot use native Node TCP drivers (must use HTTP or WebSocket database drivers like Neon or Prisma Accelerate).