PHP 应用程序的应用程序性能管理
我正在寻找 PHP 的应用程序性能管理(请参阅 http://en.wikipedia.org/wiki/Application_performance_management )
该工具可以插入生产中的任何 PHP 应用程序,并且可以收集/显示有关每个请求的 PHP 执行时间、网络时间、数据库查询时间的统计信息。对于每个指标,我想查看最小值、最大值和平均值。
所有这些统计数据都可以实时获取,也可以获取过去的数据。
有没有现有的工具可以做到这一点?欢迎提出任何工具(免费或免费)的建议。
I am looking for an application performance management for PHP (see http://en.wikipedia.org/wiki/Application_performance_management)
This tool could be plugged to any PHP application in production, and can collect/display statistic about PHP execution time, network time, db query time for each request. For each indicator, I would like to see the min, max and average value.
All these statistics would be available in real time and also for the past.
Is there any existing tool which can do that? Suggestion for any tools (free or not) are welcome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
(/我深吸一口气)
让我们一次处理这一行:
您可能不会从不知道 APM 是什么的人那里得到非常明智的答案。
这意味着您正在寻找 PHP 代码解决方案 - 这可能是您应该尝试解决问题的最后一种方法。
好吧,唯一可以可靠地测量这一点的地方是在 PHP 代码中 - 但这是解决问题的蹩脚方法。
哪个网络时间?在响应开始返回客户端之前至少有 2 次往返,PHP 都看不到这两次往返。此外,您无法测量 PHP 脚本完成与客户端最终确认(或 RST)之间的延迟。
这超出了 APM 的范围。
只是为了找出您需要什么以及您可以捕获什么,需要比此处提供的更深入的分析。不过,我建议您不要尝试检测代码来获取这些指标。
许多信息可以被网络服务器捕获 - 假设它是 Apache,请确保您正在记录 %D 和 %X。
解决该问题的最佳方法之一是数据包嗅探。如果您没有预算,例如 Client Vantage 或 Nimsoft的解决方案,您可能需要查看 Pastmon。
尽管其中更昂贵的声称能够重建页面转动响应时间,但我的经验是,他们经常遇到除纯静态内容之外的任何问题。如果向他们扔一个PRG,他们就会完全迷失方向。
如果你想测量翻页响应,那么有两种方法
使用日志分析(如果你还没有一些用户跟踪功能,请为 Apache 设置 mod_usertrack - 并启用相应的用户和 mime 日志记录)然后你可以获得从“text/html”请求开始到最后一个非“text/html”请求结束的页面转动时间估计。不幸的是,我不知道有任何现成的软件包可以提供这种分析。
使用 JavaScript 将超时推送到浏览器。这就是 Oracle 的 EUPM 的工作原理 - 但您'您需要运行具有完整网格控制安装的 Oracle 堆栈才能看到结果。但请查看剧集对于一个非常有前途的架构的骨架(值得注意的是,微软有 发明了一些看起来非常相似的东西!) - 当我赢得彩票并退休时,我可能会尝试为剧集建立支持Piwik 的爱好。
虽然有很多人愿意向您出售具有上述所有功能的软件包,但在很多情况下,他们实际提供的内容与您正在测量的内容之间存在一些语义差异。例如,他们中的许多人假设服务器端处理在服务器开始响应时完成 - 这显然是无稽之谈,尽管它可以被视为系统状态的一致指示器(另请参阅mod_log_firstbyte)
HTH
(/me takes a deep breath)
Lets deal with this one line at a time:
You're probably not going to get very sensible answers from people who don't know what APM is.
This rather implies you are looking for a PHP code solution - that's probably the last way you should attempt to solve the problem.
OK, the only place you can reliably measure this is within the PHP code - but its a crappy way to solve the problem.
Which network time? There's at least 2 round trips before the response starts to come back to the client, neither of which PHP can see. Also you can't measure the delay between completion of the PHP script and the final ack (or RST) from the client.
This is getting outside the scope of APM.
Just to find out what you need, and what you can capture would require much more in-depth analysis than can be provided here. However I would recommend that you do not try to instrument your code to get these metrics.
A lot of the information can be captured by the webserver - assuming its Apache, do ensure that you are logging %D and %X.
One of the best approaches to solving the problem is by packet sniffing. If you've not got the budget for something like Client Vantage or Nimsoft's solutions, you might want to have a look at Pastmon.
Although the more expensive of these claim to be able to reconstruct page turn response times, my experience is that they often have problems with anything other than plain static content. Throw a PRG pater at them and they get completely lost.
If you want to measure page turn response, then there are 2 approaches
use log analysis (do set up mod_usertrack for Apache if you don't already have some user tracking functionality - and enable the corresponding user and mime logging) then you can get an estimate of page turn times from the start of the 'text/html' request to the end of the last non-'text/html' request. Unfortunately I am not aware of any off-the-shelf package which provides this kind of analysis.
push the timing out onto the browser using javascript. This is how Oracle's EUPM works - but you'll need to be running an Oracle stack with a full Grid Control installation to see the results. But do have a look at Episodes for the bones of a very promising architecture (remarkably Microsoft have invented something which looks remarkably similar!) - when I win the lottery and retire I might try building support for Episodes into Piwik for a hobby.
While there are lots of people willing to sell you packages which do all the above, in a lot of cases there are some semantic differences between what they actually provide and what you are measuring. E.g. a lot of them assume that server side processing completes when the server begins the response - which is patently nonsense, although it can be treated as a consistent indicator of the state of the system (see also mod_log_firstbyte)
HTH
看看 NewRelic。它涵盖了您正在寻找的所有信息。我没有对 PHP 堆栈的开销进行精确的独立测量,但不久前我对 java 堆栈进行了广泛的测量,结果在 2-5% 的范围内。该公司声称 PHP 开销大致相同,我倾向于相信他们。
Take a look at NewRelic. It covers all of the information you're looking for. I don't have an exact independent measurement of overhead for the PHP stack, but I did extensive measurement of the java stack a little while back, and it was in the 2-5% range. PHP overhead is claimed by the company to be about the same, and I'd tend to believe them.
APM 工具种类繁多,它们的工作方式各不相同,并且能够收集不同的统计数据。以下是一些示例,说明不同工具的工作原理以及为什么它们可能或多或少有用,具体取决于您要监视的内容:
There's a wide range of APM tools and they all work differently and are capable of collecting different statistics. Here are some examples of how different tools work and why they might be more or less useful depending on what you're trying to monitor:
要分析 PHP 应用程序,您可能需要查看 XHProf:
http://pecl.php.net/package/ xhprof
http://techportal.inviqa.com/2009 /12/01/profiling-with-xhprof/
For profiling PHP applications, you might want to check out XHProf:
http://pecl.php.net/package/xhprof
http://techportal.inviqa.com/2009/12/01/profiling-with-xhprof/