Skip to main content
Penyaskito Blog

Main navigation

  • Home
  • Contact
Language switcher
  • English
  • Español
User account menu
  • Log in

Breadcrumb

  1. Home

WordPress

By penyaskito, 1 May, 2021
Screenshot of XHGui, showing information from a WordPress request

Profiling Drupal, WordPress or any php application with DDEV, XHProf and XHGui

I've been a very late adopter of Docker containers. Probably because most of my work in the last years was not dependent on the PHP version, so I used the same PHP version and MySQL/MariaDB as RDBMS every time. For a server I managed I played with LXC as a container system, and served quite well, but I didn't really need to touch it often, and my friend Andrés helped most of the times. Docker seemed confusing to me and, hold my beer, I thought it wouldn't stay, so I didn't really want to learn it. You might say now that my career as seer is over.

Not easily but I got to understand it, and really embraced and loved tools like docker-compose on top of docker. And when I had to work on a Drupal site using Postgres, my best bet was DDEV, abstracting docker-compose complexities but with all the freedom to customize it for your needs.  So that's my platform of choice most of the times in terms of local environments now. And lucky us, it's open source.

And the implicit non-enforced well-citizen contract of opensource is that you have to contribute back if you get the chance to improve it*. In minor contributions I've done before I found the DDEV community really encouraging and welcoming, thanks Randy! So lately I was in the need of  detecting performance bottlenecks in a site, and I've been working on integrating the provided XHProf with XHGui into DDEV. I recently contributed the recipe so you can use it too in less than 5 minutes! See it here: XHGui integration in DDEV documentation. 

* Needed clarification: not saying that you have to give back, not everyone has the same privilege than I do. But *if you did accomplish it already, try to contribute it*. 

If you enable XHProf, already provided with DDEV, it already monitors your application, but you need to collect that profiling report and send it somewhere where you can explore it in a friendly way. That's where perftools/php-profiler comes into play. It has the ability to manage which data you want to profile, and send it to XHGui. XHGui will run on a separate container, will receive the data profiled, store the data in a mongodb database in another container, and render it to you on the browser, where you can see several listings, graphs and images that will help you understand what's going on on your application. You can also compare different requests to a same page, so you see how the performance evolves too. Interpretation of that data is a complex topic on its own, so I won't go deeper here.

So the good news is that you can integrate that now into any project you have with DDEV, in less than 5 minutes. The docs are specific for Drupal 8+ (a composer project) and WordPress (a non-composer project, kudos to roots/bedrock for changing that), so that probably covers examples for any PHP application out there.  Hope this helps!

As a bonus track, I also worked on a DDEV command for enabling/disabling xhprof without having to restart  your project, type a very long command or ssh into the container. That's on that DDEV-contrib page too, but it's probably going to be accepted upstream in DDEV soon too.

Thanks Randy "rfay" Fay, Andrey "andypost" Postnikov and Mateu "e0ipso" Aguiló for the feedback, help and inspiration on working on this! 

Tags

  • docker
  • docker-compose
  • php
  • XHProf
  • DDEV
  • XHGui
  • WordPress
  • Drupal
  • Drupal planet
WordPress

Monthly archive

  • December 2021 (1)
  • May 2021 (2)
  • April 2021 (1)
  • September 2014 (1)
  • November 2012 (1)
  • September 2012 (2)
  • August 2012 (3)
  • June 2012 (6)

Recent content

Rewriting history on a git repository for editing author and email on past commits
1 year 3 months ago
A Drupal JavaScript behavior for marking edited line items in the cart
1 year 10 months ago
Profiling Drupal, WordPress or any php application with DDEV, XHProf and XHGui
1 year 10 months ago
A personal site upgrade from Drupal 7 to Drupal 9: some migration tips
1 year 11 months ago
Salesforce: generating Excel files from VisualForce APEX pages
8 years 6 months ago
Drupalcamp Spain 2012
10 years 4 months ago
Non-interactive performance tests and reporting with JMeter
10 years 6 months ago
Git workflow with submodules for Drupal deployment
10 years 6 months ago
Remoting for the Drupalcon Munich D8MI Sprint
10 years 7 months ago
Drupal Sevilla Talk: Contributing to Drupal
10 years 7 months ago

Recent comments

Thanks for the comment
1 year 10 months ago
Thanks for sharing this…
1 year 10 months ago
Looking good!
1 year 11 months ago
lopd
8 years 11 months ago
LOPD
9 years ago
Gridinit
10 years 5 months ago
Ya la tiene
10 years 6 months ago
Debería :-P
10 years 6 months ago
Ei! tiene buena pinta...
10 years 6 months ago
Buenas Fco Antonio,
10 years 6 months ago

Blogs I follow

Mateu Aguiló "e0ipso"
Gábor Hojtsy
Pedro Cambra
The Russian Lullaby, davidjguru
Can It Be All So Simple
Maria Arias de Reyna "Délawen"
Matt Glaman
Josef Ottosson (dotnet)
Daniel Wehner
Jacob Rockowitz
Syndicate

Footer

  • Contact
  • Drupal.org
  • LinkedIn
  • GitHub
  • Twitter
Powered by Drupal