cakephp - Controller::invokeAction 花费大量时间

cakephp - Controller::invokeAction taking lot of time

我正在研究 cakephp 2.x。我在 New Relic 的事务跟踪摘要中发现,有一些 API 需要花费大量时间(几乎 20-30 秒)来执行,其中几乎 90% 的时间花在 Controller::invokeAction方法。

谁能解释一下为什么在 invokeAction 方法上花费了这么多时间。

我同意@ndm 的观点,Controller::invokeAction() 方法封装了控制器操作触发的所有内容。您的方法没有花费太多时间来执行,但是当它将结果数据发送到客户端时 - 完成卸载数据所需的时间会记录到此方法中。用 New Relic 的说法,这是 未检测的时间

New Relic 的交易时间也包括这个网络时间,这将被记录到 Controller::invokeAction() 方法中,因为 New Relic 找不到其他可归咎于未跟踪时间的操作。

根据 New Relic 文档 -

the most frequent culprits are functions that send large blocks of data or large files to users. If the user is on a slow connection, sending small files (small images for example) could take a long time due to simple network latency. Since no internal or C extension functions are instrumented, the PHP agent has no one to "blame" the time spent on, and this appears in a transaction trace as uninstrumented time.

您可以在此处阅读更多相关信息 https://docs.newrelic.com/docs/agents/php-agent/troubleshooting/uninstrumented-time-traces

如果您仍然想弄清楚发生了什么,或者跟踪您的方法的未检测时间;您可以在 New Relic 的 PHP 代理中将 newrelic.transaction_tracer.detail 设置为 0。这将确保最大的可见性。

您可以在此处阅读有关设置 New Relic 的 PHP 自定义工具的更多信息:https://docs.newrelic.com/docs/agents/php-agent/features/php-custom-instrumentation