Why this matters
Most products mix platforms: a Next.js frontend on Vercel, a Python API on a container platform or VM, a managed database. Picking well saves weeks of operations work; picking badly creates surprise bills or timeouts on long AI requests.
Options compared
| Option | Good for | Watch for |
|---|---|---|
| Vercel | Next.js and frontend; serverless and Node/Python functions; previews per PR | Function duration and body-size limits; framework detection |
| Railway / Render / Fly.io | Containers and simple backends with little ops | Pricing at scale; regions |
| AWS ECS/Fargate, Cloud Run | Production containers with autoscaling | More configuration |
| A VM (EC2) with Nginx + systemd | Full control, long-running or heavy jobs (FFmpeg, GPUs) | You own patching, scaling, monitoring |
| Kubernetes | Many services, platform teams | Operational complexity; rarely needed early |
A real example from the casebook (P1): Next.js studio on Vercel; FastAPI + FFmpeg on an EC2 instance behind Nginx and systemd; a private encrypted S3 bucket with a least-privilege role. Heavy media processing doesn't fit serverless limits, so it runs on a VM.
How to do it: deploy checklist
- Build settings: framework preset, build command, output directory, runtime version.
- Environment variables per environment (preview, staging, production); secrets never in the repo.
- Health check endpoint that verifies dependencies.
- Domains and TLS.
- Rollback path: previous deployment one click away.
- Logs and alerts wired before launch, not after.
Reading a failed deploy
Read the build log from the bottom up, then find the first error. A real example: a Next.js static export built successfully, but the platform failed afterwards with "No Output Directory named 'public' found". The build was fine; the project was configured with the "Other" framework preset, which expects public/, while output: "export" writes out/. Fix: set the framework to Next.js (in project settings or vercel.json "framework": "nextjs"), or set the output directory to out. The lesson: a green build step doesn't mean a correct platform configuration.
Common mistakes
- Different Node or Python versions locally and in the build.
- Long AI requests on serverless functions with short time limits; move them to background jobs or streaming.
- Preview deployments wired to the production database.
Interview follow-ups
- "Serverless or containers for an AI API?" Serverless suits spiky, short requests; containers suit long streaming responses, steady load, heavy dependencies, and connection pooling to databases.
- "How do preview environments get databases?" Branching databases (Neon, PlanetScale-style) or seeded ephemeral databases per PR, never production.
Check yourself
Where would you deploy a Next.js frontend, a FastAPI AI gateway, and a video rendering worker?
Frontend on Vercel (or similar); the gateway on a container platform with autoscaling and long timeouts for streaming; the renderer on VMs or container tasks with enough CPU/memory and no short time limits, fed by a queue.
The build succeeds but the deploy fails with "no output directory". What do you check?
The platform's framework preset and output-directory setting versus what the build actually writes (for example out/ for a Next.js static export).
Build it
Deploy your Next.js frontend and FastAPI backend to two platforms, with separate preview and production environment variables and a health check.