How Hosting Works
From code on your laptop to users around the world — the complete hosting stack explained
Skills taught: deployment.hosting-fundamentals, deployment.servers, deployment.hosting-types, deployment.static-vs-dynamic
What actually happens when someone visits your site
When a user types myapp.com in their browser, a remarkable chain of events happens in milliseconds: a DNS lookup translates the domain to an IP address, a TCP connection is established, a TLS handshake encrypts the channel, an HTTP request is sent, a server processes it, and a response is returned. Hosting is the art of making that chain work reliably, quickly, and securely for all your users simultaneously.
User types: https://myapp.com/dashboard
1. DNS Resolution (0-50ms)
Browser → DNS server
'What IP is myapp.com?'
DNS → '203.0.113.42'
2. TCP Connection (10-100ms depending on distance)
Browser → 203.0.113.42:443
Three-way handshake: SYN → SYN-ACK → ACK
3. TLS Handshake (10-50ms)
Client: 'I support TLS 1.3, here are my cipher preferences'
Server: 'Here's my certificate, let's use this cipher'
Both: derive shared encryption keys
All further communication is encrypted
4. HTTP Request (sent over encrypted connection)
GET /dashboard HTTP/2
Host: myapp.com
Cookie: session=abc123
5. Server Processing (1ms - 2000ms)
Web server (Nginx) receives request
Routes to application (Node.js, Python, etc.)
Application runs business logic, queries database
Returns response
6. HTTP Response
200 OK
Content-Type: text/html
<html>...</html>
7. Browser renders the HTML, loads CSS/JS/images (parallel requests)
Types of hosting — the spectrum
STATIC HOSTING (HTML/CSS/JS files only)
What: Files served directly from a file server or CDN
Examples: GitHub Pages, Vercel, Netlify, Cloudflare Pages, S3
Runs: React, Vue, Svelte (built), plain HTML sites, docs
Cost: Free to ~$20/month
Scaling: Automatic (CDN edge nodes handle any traffic)
Ops: Near zero — just deploy files
SERVERLESS (functions)
What: Code runs on-demand per request, no persistent server
Examples: Vercel Edge Functions, AWS Lambda, Cloudflare Workers
Runs: API endpoints, server-side rendering, webhooks
Cost: Pay per request (usually very cheap, first 1M free)
Scaling: Instant (platform handles everything)
Ops: Near zero — upload code, it runs
CONTAINER PLATFORMS (managed)
What: Your Docker container runs on managed infrastructure
Examples: Railway, Render, Fly.io, AWS ECS Fargate
Runs: Any containerized app — Node.js APIs, Python, Go
Cost: $5-50/month for small apps
Scaling: Auto-scaling available
Ops: Low — deploy containers, platform manages servers
VPS / DEDICATED SERVER
What: You get a Linux VM, full control
Examples: DigitalOcean, Linode, Hetzner, AWS EC2
Runs: Anything
Cost: $5-200/month depending on size
Scaling: Manual (you provision more servers)
Ops: High — you manage OS, web server, updates, monitoring
Rule: match hosting type to your app's needs
Start simple (static or serverless), add complexity only as needed
Static vs dynamic — understanding your stack
STATIC SITE:
Every user gets the same files
Content generated at BUILD TIME (not request time)
No server-side computation per request
Examples: marketing site, docs, blog
Frameworks: Plain HTML, Astro, Next.js SSG, Gatsby, Hugo
DYNAMIC APP:
Content varies per user/request
Generated at REQUEST TIME based on user data
Requires a running server
Examples: dashboard showing user data, social feed, e-commerce checkout
Requires: Node.js/Python/Go server + database
SPA (Single Page Application) — a hybrid:
App shell is STATIC (same HTML/JS for everyone)
But data is DYNAMIC (fetched from API after load)
React/Vue/Svelte apps are usually SPAs
→ Host the static files on CDN (free, fast)
→ Host the API separately (Node.js server)
→ Best of both worlds
SSR (Server-Side Rendering):
HTML is generated on server per request (like PHP)
Good for SEO (HTML is ready for crawlers)
Next.js / Nuxt.js support SSR
→ Requires a running server (can't use pure static hosting)
Tip: Your architecture decision determines your hosting options. A pure React SPA (Vite build) can be hosted on GitHub Pages for free — no server needed. If you add Next.js SSR, you need a platform that runs Node.js. If you add a PostgreSQL database, you need a separate database host. Make conscious choices about which features require which infrastructure.
Frequently Asked Questions
What's the difference between a web server (Nginx) and an application server (Node.js)?
A web server (Nginx, Apache) handles HTTP protocol, serves static files, terminates SSL, and proxies requests to application servers. An application server (Node.js, Gunicorn, etc.) runs your actual code and generates dynamic responses. In production, they're typically layered: Nginx listens on port 80/443, handles SSL, then forwards dynamic requests to Node.js on port 3000. Nginx is very efficient at static files and network handling; Node.js is where your business logic lives.