如何计算“应力”由服务器上的php脚本完成?
我在本地网络服务器上测试一些新的库,其中一些很重,例如 pdf 转换器(TCPDF)。我想知道php脚本占用了多少系统资源,比如cpu压力。有没有一种技术可以使用相同的 php 脚本来做到这一点?
这种测试对我来说非常重要,因为我想打开一个服务(我期待大量的流量),用户将直接获得 pdf 格式的信息,所以我的服务器将必须执行 html 来一天之内编写了很多 pdf 脚本。该测试的结果将使我知道我需要购买什么托管服务。
我知道这似乎是 serverfault 的问题,但我想要一个软件解决方案(如果可能的话),就像我之前说的,可以在同一个 php 脚本上计算这个?
感谢您的帮助和指导!祝你今天过得愉快!
im testing some new libaries on my local webserver, some of them are heavy, like pdf converter (TCPDF). I will like to know how many system resources the php script takes, like the cpu stress. Is there a tecniche to do this using the same php script?
This kind of test is very importand to me because i will like to open a service (im expecting a huge ammount of trafic) were the users will have information directly on pdf format, so my server will have to execute the html to pdf script alot in one day. The result of this test will allow me to know what hosting service i need to buy.
I know this seems a question more for serverfault but i will like a software solution (if it is possible), like i said before, is possible to calculate this on the same php script?
Thanks for any help and orientation! have a nice day!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
来自: http://www.codingforums.com/archive/index.php /t-62579.html
exec()
将不可用安全模式是否已启用。如果是,请尝试memory_get_usage()
和getrusage()
。getrusage()
返回 来自 linux 调用的结构getrusage
。如果您想知道,
$load
数组将包含过去 1 分钟、5 分钟和 15 分钟的平均 CPU 负载。From: http://www.codingforums.com/archive/index.php/t-62579.html
exec()
won't be available is safemode is enabled. If it is, trymemory_get_usage()
andgetrusage()
.getrusage()
returns the struct from the linux callgetrusage
.In case you were wondering, the
$load
array will contain the average CPU load for the past 1, 5, and 15 minutes.使用 ab 之类的内容对您的 Web 应用程序进行负载测试。这将使您能够对软件和基础设施执行快速而肮脏的高级测试。
示例:
将以 10 个并发批次的方式向重型脚本发出 1000 个请求,然后转储包含
requests/second
、time/request
等指标的报告。Load test your webapp with something like ab. This will allow you to perform a quick and dirty high level test of your software and infrastructure.
Example:
Would make 1000 requests to your heavy script in concurrent batches of 10 and subsequently dump a report with metrics like
requests/second
,time/request
etc.