How Servers Run Your Code
"Web servers were built to serve static files. Dynamic content — shopping carts, logins, database queries — requires the server to run code. The question is: how does that code execute?"
CSE 135 — Full Overview | Review Questions
Web servers serve files — but dynamic content requires running code.
Four approaches, each with different trade-offs.
| Model | How It Works | Examples | Era |
|---|---|---|---|
| Fork-Exec CGI | Server spawns a new process for each request | Perl, C programs | 1993 |
| Server Module | Interpreter embedded in the server process | mod_php, mod_perl | ~1997 |
| Application Server | Persistent process handles many requests | Node.js, Python WSGI, Java Servlets | ~2009 |
| Serverless / FaaS | Cloud platform manages execution | AWS Lambda, Cloudflare Workers | 2014 |
The original (1993) solution — a new process for every request.
Embed the interpreter inside the web server — no fork overhead.
The application IS the server — a persistent process handling all requests.
Side-by-side trade-offs across all three models.
| Aspect | CGI | Module (mod_php) | App Server (Node.js) |
|---|---|---|---|
| Startup per request | Full process (fork+exec) | None | None |
| Memory isolation | Complete | Partial | None |
| State between requests | Impossible | Limited | Easy (in-memory) |
| Requests per second | ~100s | ~1,000s | ~10,000s |
| Crash impact | One request | One Apache worker | ALL requests |
| Deployment | Drop files | Drop files | Process manager |
See each execution model in action with live examples.
The evolution of server-side execution reflects the web's growth.
8 sections of execution model fundamentals in one table.
| Concept | Key Points |
|---|---|
| The Challenge | Web servers serve static files. Dynamic content requires an execution model to invoke code and capture output. |
| The Models | Four approaches: CGI (fork-exec), Server Module (embedded), Application Server (persistent), Serverless (cloud-managed). |
| CGI | New process per request. Complete isolation, any language, but high overhead (~100 req/s). The original 1993 model. |
| Server Module | Interpreter inside the server (mod_php). No fork overhead, ~1,000s req/s, but language tied to server and shared memory risks. |
| Application Server | Persistent process (Node.js). ~10,000s req/s, in-memory state, but crash kills all connections. Needs reverse proxy. |
| Comparison | Performance scales up (CGI → Module → App Server) but crash impact scales inversely. More sharing = more throughput but greater blast radius. |
| Demos | Perl and C for CGI, PHP for mod_php — same operations in different languages and execution models. |
| History | CGI (1993) → mod_perl (1997) → Node.js (2009) → Lambda (2014). Each solved the previous model's bottleneck. All coexist. |