There are several distinct models for executing server-side code to generate dynamic web content. Each model has different trade-offs in terms of performance, portability, and complexity. Understanding these models helps you choose the right approach for your application.
1. Fork/Exec (CGI)
The traditional CGI (Common Gateway Interface) model. For each request, the web server forks a new process and executes the script. The script runs, produces output, and terminates.
2. Server-Side Scripting (Embedded Interpreter)
The scripting interpreter runs inside the web server process as a module. Scripts are parsed and executed without forking new processes, eliminating the fork/exec overhead.
Historical: Classic ASP, ColdFusion, JSP, ASP.NET
3. Embedded Native (Server Modules)
Custom code compiled directly into the web server as a native module. The code runs as part of the server process with full access to server internals. Maximum performance but requires recompilation for changes.
Other: IIS ISAPI extensions, nginx modules
4. Code as Server (Standalone Application Server)
The application runs its own HTTP server as a persistent process. A traditional web server (Apache, nginx) acts as a reverse proxy, forwarding requests to the application server. This is the dominant model for modern web applications.
Other: Ruby on Rails (Puma), Go (net/http), Java (Spring Boot), Rust (Actix)
Note: Performance varies significantly by language runtime. Node.js (V8) is faster than Python (Flask). Go and Rust approach native performance. The proxy layer adds latency compared to embedded approaches.
Model Comparison
| Model | Performance | Portability | Difficulty | Best For |
|---|---|---|---|---|
| Fork/Exec (CGI) | Low | High | Medium | Simple scripts, infrequent requests |
| Server-Side Scripting | Medium | Medium | Low | Traditional web apps, CMS systems |
| Embedded Native | Highest | Low | High | Maximum performance, server extensions |
| Code as Server | Medium-High* | High | Medium | Modern web apps, APIs, microservices |
*Code as Server performance varies by language: Go/Rust approach native speed, Node.js is fast, Python/Ruby are slower. Proxy layer adds latency vs embedded approaches.