[英]Can python script (Or any other programming language scripts) be used to restrict resources (like RAM, CPU Usage) used by other applications?
For my project, I am supposed to measure system performance of OpenStack SWIFT based on available resources like RAM, CPU, etc.. So, I was wondering, can I use a python script or some other programming language scripts to restrict the resources usage by OpenStack SWIFT to measure the impacts of those resources on the OpenStack SWIFT ??? 对于我的项目,我应该根据RAM,CPU等可用资源来测量OpenStack SWIFT的系统性能。所以,我想知道,我可以使用python脚本或其他一些编程语言脚本来限制资源的使用OpenStack SWIFT测量这些资源对OpenStack SWIFT的影响???
Please reply!!! 请回复!!!
By using python resource module you can set the resource limit, please check more detail in the official docs resource 通过使用python资源模块,您可以设置资源限制,请在官方文档资源中查看更多详细信息
import resource
resource.setrlimit(resource.RLIMIT_CPU, (1, 1))
By using subprocess you can change the ulimit : system wide resource and nice level ie scheduling priority. 通过使用子进程,您可以更改ulimit :系统范围的资源和良好的级别,即调度优先级。
import subprocess
subprocess.Popen('ulimit -t 10; nice -n 15 application_name', shell=True)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.