CGI,FastCGI,PHP-CGI,PHP-FPM,Spawn-FCGI

來源:互聯網
上載者:User

標籤:turn   inf   http   cal   color   res   sam   gateway   tar   

CGI
  • CGI, Common Gateway Interface, is a tool for HTTP server to contact with programs on other servers, which can be used into any languages with standard input, standard output and environmental variables, such as PHP, Perl, or Tcl.
FastCGI
  • FastCGI is a kind of CGI which is long-live, which will always be running. With FastCGI, it‘ll take less time t fork(which is a problem of fork-and-execute mode in CGI). In additional, FastCGI also supports for distributed computing.
  • It is also not language related, which is an opened extension of CGI, which is used to keep CGI running in the memory. It‘s well-known that loading of CGI has been the main reason of low performance.

  • the main process of running FastCGI:

    1. Loading the Process Manager of FastCGI when a Web server has booted(IIS ISAPI or Apache Module)
    2. The Process Manager of FastCGI will initiate itself to create several CGI processes, which are used to wait for connection of Web servers.
    3. When requests from clients have reached the Web server, the Process Manager of FastCGI will select a CGI set up before to connect, whose environmental variables and standard input will be sent to the sub process php-cgi of FastCGI.
    4. This sub process will return standard output and error info to the Web server with the same connection. Requests will be finished when it closes the connection.
  • Therefore, FastCGI only set once for parsing php.ini, loading extensions and initiating all the data structures.
shortcuts
  • Because of multi-processes, FastCGI will cost more memory than CGI, whose each process(PHP-CGI) will cost about 7Mb to 25Mb memory.
  • Data from the article: Nginx 0.8x + PHP 5.2.13(FastCGI) is 10 times better than Apache(Edition 6)
  • when 30k connection happens in parallel, 10 Nginx processes will only cost 150Mb Mem(15Mb 10), and 64 PHP-CGI will only cost about 1280Mb(20Mb 64).
PHP-CGI
  • PHP-CGI is one kind of the Process Manager of FastCGI, which is within php itself.
  • The command to boot is as follow:
php-cgi -b 127.0.0.1:9000
shortcuts
  • After changing php.ini, you should reboot PHP-CGI to make the new php.ini work.
  • When a PHP-CGI process is killed, all the PHP code will cannot run.(PHP-FPM and Spawn-FCGI do not have the same problem)
PHP-FPM(Fast-CGI Process Manager)
  • PHP-FPM is another kind of the Process Manager of FastCGI, which can be downloaded here.
  • It‘s actually a patch for PHP, which is used to integrate the Process Manager of FastCGI into PHP, which should be make into PHP before version 5.3.2(5.3.2以後已經整合於php中).
  • PHP-FPM can be used to control sub processes of PHP-CGI:
/usr/local/php/sbin/php-fpm [options]# options# --start:      start a fastcgi process of php# --stop:       force to kill a fastcgi process of php# --quit:       smooth to kill a fastcgi process of php# --restart:    restart a fastcgi process of php# --reload:     smooth to reload php.ini# --logrotate:  enable log files again
Spawn-FCGI
  • Spawn-FCGI is a general kind of the Process Manager of FastCGI, which is one part of lighttpd.

CGI,FastCGI,PHP-CGI,PHP-FPM,Spawn-FCGI

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.