HipHop is a PHP compiler project developed by Facebook. hipHop first converts PHP code into C ++ code, and then uses the C ++ compiler such as GCC to compile the target machine code. hipHop is used to improve the efficiency of Facebook servers. currently, over 90% of Facebook website traffic is processed by HipHop-compiled PHP code. hipHop also uses a series of PHP script code
HipHop is a PHP compiler project developed by Facebook. hipHop first converts PHP code into C ++ code, and then uses the C ++ compiler such as GCC to compile the target machine code. hipHop is used to improve the efficiency of Facebook servers. currently, over 90% of Facebook website traffic is processed by HipHop-compiled PHP code. hipHop also uses a series of PHP script code
HipHop is a PHP compiler project developed by Facebook.
HipHop first converts PHP code into C ++ code, and then uses the C ++ compiler such as GCC to compile the target machine code.
HipHop is used to improve the efficiency of Facebook servers. Currently, over 90% of Facebook website traffic is processed by PHP Code Compiled by HipHop.
HipHop also compiled a series of PHP script code into a multi-threaded WEB server. In this way, the compiled PHP Code not only runs faster, but also makes better use of the system memory.
Multi-threaded WEB servers use less memory because they use a single memory pool to process all concurrent requests.Pre-ForkMode.
Currently, most php web servers use the multi-process mode. In this mode, each request is processed by different system processes. Each process has its own memory pool.
The main problem with the multi-process mode is that if a process occupies a large amount of memory, the memory cannot be returned to the system before the process exits, even if the process does not need so much memory for subsequent requests, the extra memory space cannot be used to process other concurrent requests.
In Apache design, a process can be forcibly disabled within a certain period of time, so that the memory can be used cyclically. However, there will always be a waste of memory before the process exits.
Memory usage is critical for large websites because it determines the number of concurrent requests that the WEB server can process.
For example, if you have a WEB server with 1 GB of memory and each PHP request occupies 10 MB, the number of concurrent requests that can be processed simultaneously is theoretically 100.
If the memory used by applications running at the same time exceeds the available physical memory, the operating system will enable virtual memory to replace some memory blocks in the physical memory to the virtual memory area of the disk, in this way, the system performance will rapidly decline.
Excessive concurrent requests can paralyze the server, that is, DOS ). For Apache, you can use the configuration item MaxClients to limit the number of concurrent workers, so that requests that exceed the limit will enter the service queue to avoid server paralysis. However, this means that some requests will be processed in a delayed manner or even ignored.
Multithreading or multi-process mode has actually been discussed before: use of multi-threaded Web servers for handling high traffic. note: This article only recommends using multi-threaded WEB servers to process static file slices, CSS and Javascript.
A new aspect of HipHop is that Facebook engineers have converted PHP extensions into thread-safe code.
By the way, there are some non-machine code PHP compilers, such as querus and Project Zero compiled into Java bytecode, or Phalanger compiled into. NET assemblies.