How to run php on multicore pc
I want to run php on a coreI7 computer system. is there any 开发者_开发百科way to run the php on 64bit mode and use all capability of cores + hyperthread enabled.
PHP does not support creating threads.
You can fork new processes with pcntl_fork, but this is often not possible or practical when running in a web context, since in most Apache+PHP configurations you'll end up with forking Apache which will fail or give undefined behaviour.
On the other hand, each Apache process will automatically be scheduled for one of the cores, and they will end up on different cores anyway. So there's still use for multicore even in a web context.
Like always: Depends on the application, but usually no. There are not that much applications out there (in any language), that make use of more than one core, than you might expect.
However, PHP is designed as "run and die", means: Usually it runs only once and then terminate. This means, that additional processes are usually not required and maybe would slow down the whole execution (process creation and stuff). There are some functions, that allows you to create multi-process applications, but I don't think, that you have an idea for an application, where this is useful.
精彩评论