Over a million developers have joined DZone.
Platinum Partner

Speed Up Your PHP Like Facebook

· Web Dev Zone

Easily build powerful user management, authentication, and authorization into your web and mobile applications.Download this Forrester report on the new landscape of Customer Identity and Access Management, brought to you in partnership with Stormpath.

Facebook works well. NoSQL received a huge boost when people learned that Facebook uses Cassandra. But how much do people care that Facebook uses PHP?

Not just any PHP -- they 'rewrote the compiler', or rather wrote a translator that converts PHP into C++, then compiles with g++.

But Facebook did more for PHP: they also created XHProf, a PHP profiler with a (supposedly) easy-to-use HTML interface, designed to pinpoint exactly where your bottlenecks are appearing, so that you can optimize at every stage in the pipeline. Here's how the github readme describes it:

XHProf is a function-level hierarchical profiler for PHP and has a simple HTML based user interface. The raw data collection component is implemented in C (as a PHP extension). The reporting/UI layer is all in PHP. It is capable of reporting function-level call counts and inclusive and exclusive wall time, CPU time and memory usage. Additionally, it supports ability to compare two runs (hierarchical DIFF reports), or aggregate results from multiple runs.


If you haven't tried XHProf, you might want to look into it. Installation apparently requires a little nudging, but Nick Lewis just posted a full, practical guide to benchmarking and performance tuning your PHP and MySQL, using XHProf (as well as other techniques) -- a very nice overview of many common bottlenecks and how to open them up.

Nick also links to a great Drupal 6 performance wiki (no complaints now, plenty of users are still on Drupal 6), which is helpfully divided into subsections (big and small performance gains, bug fixes, etc.).

Both resources are worth checking out, especially if you're beginning to feel like PHP runs slowly (when in fact you haven't optimized nearly as well as you could).

 

The Web Dev Zone is brought to you by Stormpath—offering a complete, pre-built User Management API for building web and mobile applications, and APIs. Download our new whitepaper: "Build Versus Buy: Customer Identity Management for Web and Mobile Applications".

Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}