Get the latest tech news

Serving 200M requests per day with a CGI-bin


In the early 2000s, we used to write a lot of CGI programs. This was the primary way to make websites dynamic at the time. These CGI programs were usually written in Perl, but sometimes in C or other languages to increase performance. The CGI mechanism is conceptually simple but powerful. When the web server receives an incoming request for a CGI script (e.g. /~jakegold/cgi-bin/guestbook.cgi), it: Sets up environment variables containing request metadata (HTTP headers, query parameters, request method, etc.) Spawns a new process to execute the CGI program Passes the request body (if any) to the program via stdin Captures the program’s stdout as the HTTP response Sends any error output from stderr to the error log The CGI program reads the environment variables to understand the request, processes it, and writes an HTTP response to stdout, starting with headers.

The CGI program reads the environment variables to understand the request, processes it, and writes an HTTP response to stdout, starting with headers. One of the nice features of this is that the CGI program exits after handling a single request, so all of its file descriptors and memory are automatically freed by the operating system. I haven’t analyzed the results in much detail (I need to go to sleep), but the basic takeaway is that CGI is impressively fast on modern servers.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Day

Day

Photo of bin

bin

Photo of M requests

M requests

Related news:

News photo

Won’t somebody think of the European children? Meta and Google put up their hands to help on the same day

News photo

Google fixes fourth actively exploited Chrome zero-day of 2025

News photo

Citrix bleeds again: This time a zero-day exploited - patch now