Published
8/12/2015
Categories
Software

Troubleshoot PHP Performance Issues With Blackfire Profiler

The situation: One of our clients was experiencing an issue where logging into their site took a couple minutes. We have performance monitoring on their server and couldn’t spot anything out of the ordinary for the CPU, memory usage, web workers, etc. It’s probably an issue in the PHP app layer we thought and a perfect excuse to give Blackfire Profiler a try!

Installing Blackfire Profiler was a breeze. We typically run RHEL/CentOS and Blackfire.io is an excellent example of how software should provide installation docs and packages. (If it’s too difficult to install then how will it gain adoption?) First was the yum repo, then agent, and finally PHP probe. Even the IDs and tokens are embedded into the docs. Beautiful!

What’s next?  We wanted to profile a web page so we installed Blackfire Companion for Chrome but turns out that it doesn’t run a profile like XDebug on the next request. After a quick search we found that we should use the “blackfire curl” call (explained in documentation here) to profile the login submission. The tip on Chrome’s “Copy as cURL” made it almost too simple.

Warning: in the YouTube video that explains the process, they add they add a -I (headers only output) to the end but that was giving us a “Error while running command: exit status 4″ error. Removing the -I fixed that error.

The profile completed successfully and gave us a link to follow to view the graph. Now time to dig into the results:

Blackfire.io Slow Login Profile

Well then! That was almost too easy. A quick search in the code and turns out a 3rd party API that we use on login was responding very slowly. Looks like we forgot to set a timeout for that API call. Oops! Quick patch to add a timeout, deploy, and done.

The Conclusion

Blackfire is awesome. With 30 minutes of troubleshooting, the issue was resolved, login speed was improved, and our clients were happy campers.  If you’re having performance issues on your own web app, give it a try!

________________________ Endertech is a Los Angeles Software Development Company able to build custom development solutions. Contact us for your free consultation.