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.



import sys
from flup.server.fcgi_fork import WSGIServer

def test_app(environ, start_response):
	start_response('200 OK', [('Content-Type', 'text/plain')])
	yield 'Hello, world!\n'




use FCGI;

while (FCGI::accept >= 0) {
  print "Content-type: text/html\r\n\r\n";
  print  "Hello, world!\n";


PHP is now run through fastcgi by default. You needn't make any changes to your PHP code in order to take advantage of the speed benefits of FastCGI.