Using FastCGI
FastCGI is an extension of the CGI way of doing things. FastCGI will exec your program one time instead of once-per-request. Your program must then handle the input. Using available libraries, it is simple to use FastCGI. Here are a few examples in various interpreted languages.