Why use accelerators with fastcgi for PHP?

I am new to web technology and still on the learning curve. I heard that fastcgi will save the compiled (interpreted) php code in memory, so why use PHP caching (apc or eaccelerators) for PHP? But I have never heard of such accelerators for Python. I would expect that how python and php will interpret the language, it makes me think that there should be room for python accelerators? Pls fix me if i am wrong.

Many thanks

+4
source share
3 answers

PHP on it forgets to compile right on time, as soon as this is done with this file. This means that PHP must recompile the file every time it wants something from it. The OpCode cache (for example, you talk about it, and keep the PHP classes compiled in memory for a predetermined time).

Python, on the other hand, initially compiles things with much faster interpreted code on first run. You see all the .pyc files around your project, they are equivalent to PHP OpCode.

PHP OpCode cache is often combined into other functions (data storage with resident memory), and they are also provided in Python.

However, there are several β€œaccelerators” for Python. Most noteworthy is Psyco , which claims that under ideal conditions speed improves from 2x to 100x. But this is due to the huge cost of RAM and works only on i386 arches.

+2
source

Unlike PHP, (C) Python does not throw out bytecode after it runs. When module.py is imported and there is no .pyc module, it is compiled into bytecode and the result is copied to module.pyc; it already exists, the compilation is skipped and the ready-made module.pyc is used. You can also do the same for the main script manually.

Concerning

fastcgi will store the compiled (interpreted) php code in memory, so why use op-code caching (apc or eaccelerators) for PHP?

I never do this - FastCGI does not start a new process for each request (unlike the simple old CGI, which starts basically launching the interpreter as a new process), but this is it. This test shows that FastCGI does not work better than mod_php (i.e., an interpreter built into the Apache process).

+2
source

Python compiles to bytecode at runtime (.pyc files), and bytecode is supported, not discarded. Compiled python is used instead of the source, if present. Therefore, there is no need for additional caching of the operation code in python, since it is already built-in.

0
source

All Articles