What’s the ideal way to profile WordPress memory usage?

The apache process memory amount you talk about (80 to 120 MB per process) can be split into two reasons.

  1. Apache
  2. WordPress

Apache

You can optimize apache by only loading the number of modules you need and other optimization tweaks that will reduce the memory. If you have not optimized that yet, give it some tweaks.

WordPress

WordPress just consumes a lot of memory and is not very optimized at all. I would start with replacing the database class with something more properly implemented. That should gain more speed and reduce the memory usage a lot. Next to that I have not that much to suggest. Not using Worpdress is not considered helpful I guess.

Strategies

To find out what’s going on, you need to track how much memory a wordpress request is taking up. There is a get peak usage function (memory_get_peak_usage()) you could use to monitor worpdress memory usage. If it comes close to the 80 – 120 MB you wrote about, you know that wordpress is creating your headaches. You might want to log the time-stamp, peak memory, execution time and requested URI.

Using Nginx to serve cached wordpress pages will most certainly help you because it will prevent wordpress from getting loaded – even for those “inbound” caches like the one you use. They are conceptually broken because they are a wordpress plugin, so at least a part of wordpress needs to be loaded even for cached results.

Leave a Comment