Tuesday, July 30, 2013

AWS: Understanding PHP, PHP-FPM, and Nginx

This small article is a refresher on Common Gateway Interface (CGI), FastCGI, PHP-FPM, and Nginx operations involving PHP.

What is CGI?

As stated in RFC 3875 (CGI protocol v1.1) designed by the Internet Society (ISOC),
The Common Gateway Interface (CGI) allows an HTTP server and a CGI script to share responsibility for responding to client requests. [...] The server is responsible for managing connection, data transfer, transport, and network issues related to the client request, whereas the CGI script handles the application issues such as data access and document processing.
The way it works is that when a web server such as Apache or Nginx receives a request from a client, it executes the command to the application. The cons of CGI therefore are that a new process is started for each received request, leading to a severely cluttered server.

What is Fast Common Gateway Interface (FastCGI)?

FastCGI is essentially an evolution of CGI and has become the standard. The most essential benefit of using FastCGI over CGI is that unlike CGI, it uses persistent processes that can handle multiple requests. In fact, such requests receive responses within the same connection and additional requests might not need to create separate connections.

PHP and Nginx

The best solution for PHP interacting with Nginx is perhaps the PHP FastCGI Process Manager or PHP-FPM. The main advantage of using PHP-FPM is that it uses less memory and CPU as compared to any other standalone applications. It also daemonizes PHP, thereby turning it into a background process while providing a command-line like script for managing various PHP processes.

7 comments:

  1. Amazing article. Your blog helped me to improve myself in many ways thanks for sharing this kind of wonderful informative blogs in live. I have bookmarked more article from this website. Such a nice blog you are providing ! Kindly Visit Us big data Hadoop training and certification in Chennai | Hadoop Developer Skillset 2018

    ReplyDelete
  2. This post actually made my day. You can not imagine just how much time I
    had spent for this info! Thanks!
    kajal hot

    ReplyDelete
  3. I Got Job in my dream company with decent 12 Lacks Per Annum salary, I have learned this world most demanding course out there in the current IT Market from the Data Science Training in btm experts who helped me a lot to achieve my dreams comes true. Really worth trying

    ReplyDelete

  4. I have read your blog very useful information to everyone.Thanks for sharing and keep updating more.If you are looking for python course visit our website.
    Python Training Institute In Bangalore

    ReplyDelete
  5. Ago look force behind. Everybody full song light.technology

    ReplyDelete