|
|
|
|
|
by bad_login
3486 days ago
|
|
> When you use proper opcode caching, you avoid the startup hit. In a setup with nginx, php-fpm and symfony here is how i understand the whole process. 1. A request hit nginx
2. Nginx parse the request and send it as fastcgi protocol specify to
php-fpm.
3. Php-fpm looks it's pool of php processes if there is none
available, it starts a php process (so some code is run).
4. Php-fpm fill the $_GET,$_POST etc... variable of the running php
and give it a file to execute.
5. The php process check if the file is in opcache load the bytecode
from it otherwise compile the file to bytecode and store it to
opcache.
6. The process run the script and write back to php-fpm who write back to nginx.
So now more on 6. from the point of view of a Symfony app.
1. the app.php will include an autoloader, this mean during the
lifetime of the php process every time a new
\Some\Class\Or\Function\Or\Whatelse is encounter the autoloader
code will be run. To mitigate this composer could generate an
autoload that is an associative array of \ClassName\And\The\Like =>
filename.
2. Then it include the bootstrap.cache.php this file is a
concatenation of the Symfony classes (all or the most used) in
order to reduce autoloader calls.
3. Then it create the kernel the it load more file (from app/cache)
like the service container definition+configuration and the
routing (and maybe more stuff but i don't know).
4. Then it put $_GET,$_POST etc... on it's own abstractions
(HttpFoundation\Request etc...).
5. At this point the bootstraping is done.
And i also want to remind that a class declaration like "class House
{}" is a code, that create a datastruct that has to be run on every
request, this is also what people call bootstraping.
The bootstraping is take seriously enough to have :
1. composer -o (generate the associative array)
2. bootstrap.cache.php
3. the whole app/cache directory of symfony which i find pretty
terrible as comp. sci. point of view (choose a limited language and
build compilers to work around) even if they do a great job at
error reporting.
4. php-fpm pool of thread
5. opcache
|
|