cakephp - Controller::invokeAction taking lot of time
Asked Answered
B

1

11

I am working on cakephp 2.x. I found in the transaction trace summary of New Relic, that there are some APIs which are taking a lot of time(almost 20-30 sec) to execute out of which almost 90% of the time is spent in the Controller::invokeAction method.

Can somebody explain why so much time is spent on invokeAction method.

Bloemfontein answered 9/1, 2018 at 13:38 Comment(2)
I'm not famililar with new relic, but in case they don't give you more detailed insight, I'd suggest that you use a profiler like for example xdebug or blackfire to figure where exactly the time is spent, given that Controller::invokeAction() encapsultes everything that is triggered by your controller action, ie it's impossible for anyone here to tell where the problem is located.Gravelblind
The information you have given is not enough for anyone to be able to help. You need to see detailed analysis for functions which get called inside invokeAction. It could be either related to DB query being slow or it could be computational issue. You need to figure that outColtin
I
7

I agree with @ndm that Controller::invokeAction() method encapsulates everything that is triggered by the Controller action. Your method did not take much time to execute, but when it sends the resulting data to the client - the time it takes to finish unloading the data gets logged into this method. In New Relic's parlance this is uninstrumented time.

New Relic's Transaction time includes this network time too, which will get logged into Controller::invokeAction() method, because New Relic couldn't find some other action to blame for the untracked time.

According the the New Relic Documentation -

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.

You can read more about it here https://docs.newrelic.com/docs/agents/php-agent/troubleshooting/uninstrumented-time-traces

If you still want to figure out what happened, or trace the uninstrumented time of your method; you can set the newrelic.transaction_tracer.detail to 0 in your New Relic's PHP Agent. This will ensure maximum visibility.

You can read more about setting up New Relic's PHP custom instrumentation here : https://docs.newrelic.com/docs/agents/php-agent/features/php-custom-instrumentation

Incogitant answered 17/1, 2018 at 11:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.