在 PHP 中,我可以使用 ini 设置设置内存限制 ini_set("memory_limit","24M");
但是,我只想为我服务器上的所有 PHP 程序分配一个处理器核心.
目前,我正在使用在戴尔工作站(8GB 内存和酷睿 i7 处理器)上运行的 Windows Server 2008 R2。我通过使用 VMWare 解决了这个问题,并且只为该虚拟服务器分配了一个核心和 2GB,但是,我正在寻找每个模块或每个文件夹的配置以分配不同的处理器限制,如果可能的话。
最佳答案
您可以使用配额系统来限制用户。
http://technet.microsoft.com/en-us/library/ff384148%28WS.10%29.aspx
如果您以用户身份运行 PHP,这将起作用
If you want to limit processes running under the account with SID S-1-5-82-3006700770-424185619-1745488364-794895919-4004696415 to use only 10% of the CPU bandwidth, you would do the following; Open an administrator command prompt.
Type reg add HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Quota System\S-1-5-82-3006700770-424185619-1745488364-794895919-4004696415.
Open the Registry Editor and locate the sub key you created in the previous step.
Under this key, create a new REG_DWORD value CpuRateLimit and set its value to 10.
This will limit all the processes running under that account SID to use only 10% of the CPU.
关于PHP:如何限制处理器使用率(例如仅使用一个 CPU 核心)或 %10%?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18066739/