PHP:如何限制处理器使用率(例如仅使用一个 CPU 核心)或 %10%?

标签 php process

在 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/

相关文章:

php - 我无法在 ubuntu 上运行 artisan 命令

php - 绑定(bind)空值时应该/必须使用 PDO::PARAM_NULL 吗?

php - Web 服务器中断驱动的文件传输

c++ - 除了使用 ps 命令进行终端解析之外,是否有其他方法可以在 linux 中查找正在运行的进程

c++ - 从另一个进程获取加载的模块

c# - DoxBox 从 C# 开始

javascript - 将日志错误发送到文件

php - 如何在 laravel 5 Controller 中独立设置 cookie

linux - C 中进程的不同实例分配不同的任务

c# - 在 C# 中运行仍处于打开状态的 exe 文件