Profiling PHP with Blackfire vs Xdebug 3 in 2024
Need to set up profiling for a Laravel application on staging. Xdebug 3 profiler mode and Blackfire seem to be the two main options.
Xdebug is free, Blackfire is paid. What does Blackfire actually give you beyond what Xdebug callgrind files provide?
Blackfire is faster in practice. Xdebug profiler slows requests by 200x in my experience. Blackfire uses sampling at much lower overhead. For profiling on staging that gets real traffic, Blackfire is the only practical option.
Blackfire assertions let you write performance tests: “this endpoint must not exceed 100 function calls” or “SQL queries per request must be below 5”. Those run in CI and prevent regressions.
Xdebug callgrind files need a viewer (KCachegrind or QCacheGrind). The UI is not great. Blackfire browser extension is significantly more usable for non-trivial profiles.
For a quick one-off profile during development, Xdebug is fine and free. For team workflow with CI gates and comparison between code versions, Blackfire is worth the money.
There is also Tideways which is positioned between the two: production-safe overhead and CI integration. Worth comparing if Blackfire pricing does not fit.