Zend Optimizer (hereinafter referred to Zo) improves the execution speed of PHP applications by optimizing the code. The principle of implementation is to optimize the code that is generated by running the compiler (Run-time Compiler) before it is finally executed.
eaccelerator principle
Eaccelerator by caching the compiled PHP code into shared memory and calling it directly when the user accesses it, which can play an efficient role in accelerating. It's very efficient, from creating shared memory to finding compiled code in a very short time, and for files and code that can't be cached in shared memory, Eaccelerator can also cache them on the system disk.
Eaccelerator also support the compilation and interpretation of PHP code execution, you can use the encoder.php script to compile the PHP code to protect the code, the compiled code must run in the installation of the Eaccelerator environment. Eaccelerator compiled code can not be decompile, it is not like some other compiler tools to decompile, which makes the code more secure and efficient.
Deep analysis of Eaccelerator's opcode caching capabilities
The working principle of fastcgi is:
1. Load the FASTCGI Process Manager (IIS ISAPI or Apache Module) when the Web Server starts;
2. fastcgi the process Manager itself, start multiple CGI interpreter processes (visible in Task Manager Php-cgi.exe) and wait for a connection from the Web server.
3. When a client request arrives at the Web server, the FASTCGI process manager selects and connects to a CGI interpreter. The WEB server sends CGI environment variables and standard input to the fastcgi subprocess Php-cgi.exe.
4. The fastcgi child process completes processing and returns standard output and error information from the same connection to the Web Server. When the fastcgi child process closes the connection, the request is processed. The fastcgi process then waits and processes the next connection from the FASTCGI process Manager (running in webserver). In the normal CGI mode, Php-cgi.exe quits here.
In the above scenario, you can imagine how slow CGI is usually. Each Web request PHP must reparse php.ini, reload all DLL extensions, and reinitialize all data structures. With fastcgi, all of these occur only once when the process is started. An additional benefit is that persistent database connections (persistent DB connection) can work.
the shortage of fastcgi
Because it is a multiple process, it consumes more server memory than CGI multithreading, and the PHP-CGI interpreter consumes 7 to 25 megabytes per process, multiplying this number by 50 or 100 is a large amount of memory.
The Nginx 0.8.46+php 5.2.14 (FastCGI) server consumes 150M of memory (Nginx) with 10 15m*10=150m processes on 30,000 concurrent connections, and 64 php-cgi processes that open consume 1280M of memory (20m*64= 1280M), combined with the memory consumed by the system itself, consumes less than 2GB memory. If the server memory is small, you can simply turn on 25 php-cgi processes so that the total amount of memory consumed by php-cgi is 500M.
Reference: fastcgi optimization