3

Let's assume this is a site that has dynamic content pertaining to the user, or content that changes very often, so varnish is out. Let's also assume that there are no plugins and the theme is vanilla.

Can Wordpress be tuned so it uses less memory each request? It seems to include all libraries and functions by default. Is it all or nothing, or can it load say the media functions only if it really needs them without being lobotomized?

I was going to ask this on StackOverflow, but I'm pretty sure they would have pointed me here. Maybe ServerFault?

  • 2
    Why is the (already very low) memory footprint a problem for you? – kaiser Jan 29 '15 at 8:55
  • Your question is way too broad, there are several ways to optimize memory usage but their applicability depends on the exact things you want to do, and what are (as keiser said, probably imaginery) memory bottle necks you found? – Mark Kaplun Jan 29 '15 at 10:46
  • 1
    to put number behind my "imagenery" word, on the server I administer workdpress core + w3tc when serving a cached page take about 50k memory. This is on apach+APC. maybe you can get lower then that, but that number means that on the 8GB server, assuming on 5 are free to use, I can serve 1000 requests at the same time, or 86M page views a day, some thing most site will never get in a year. Therefor the impact of core on actual memory usage is very very slim and even if it can be improved you might not notice it in practice. – Mark Kaplun Jan 29 '15 at 11:24
  • @kaiser Sorry for not being clearer in the question, but caching is out because the content changes often (varnish is a caching layer). A default install of WP + apache uses about 15MB of memory per request in my tests. – LG_PDX Jan 30 '15 at 16:40
  • @LG_PDX And you are serving content to how many concurrent users? 1k? 500? – kaiser Jan 30 '15 at 16:43
3

The short answer is... not by much.

WordPress relies on, as scribu (a guy who started by writing very clever and useful plugins, such as Posts 2 Posts, WP CLI, Plugin Dependencies and many many others, ending up in the WP core team for a while) put it:

crappy language (PHP, an ancient version to boot) and crappy architecture (WP_Query).

Apart from this, you're not the first to ask this question.

Having said that, one might ask: why use it than? Well, WP does have a few advantages:

  1. It's popular (so you'll always find people who know what needs to be done for getting you where you want to go),
  2. it's intuitive,
  3. it's modular, hence flexible,
  4. it has most of what a website or CMS might need (so you don't need to code everything),
  5. it is a lot better than it used to be,
  6. it's going to be even better,
  7. it is here to stay, at least for the foreseeable future...

...[the list goes on endlessly, with ever less important advantages WP has over its competition]

  • @PieterGoosen, but that class has nothing to do with memory usage – Mark Kaplun Jan 29 '15 at 10:48
  • downvoted as the rule of thumb is that each new version of any software will require 10% more hardware resources then the previous one due to added features, therefor you might actually get better memory foot print on php 5.2 then 5.5. 5.5 might be a better language, but that doesn't say anything about its memory footprint. – Mark Kaplun Jan 29 '15 at 11:29
  • Great discussion and analysis of this problem at the link you provided wordpress.stackexchange.com/questions/10463/…, thank you for sharing @andrei-gheorghiu – LG_PDX Jan 30 '15 at 16:44
  • @MarkKaplun That's a strange reason for a downvote. And Andrei actually is right: Every newer PHP version used less memory. – kaiser Jan 30 '15 at 16:44
  • @kaiser citation needed. You can't introduce new feature to a language without making the interpreter less efficient. And still the memory usage depends almost always on how memory being allocated by the code being run and not by loading the loading and parsing of the code itself, therefor php version has nothing to do with how much memory is used by wordpress, this only depends on the quality of wordpress code. – Mark Kaplun Jan 30 '15 at 17:11
0

Another answer to this is to look at performance increases in PHP 5.5, PHP-NG, and HHVM over PHP 5.3 and PHP 5.4. No necessarily a direct memory efficiency gain, but using PHP < 5.5 without (especially without an opcache) is leaving a lot on the table.

Some links to benchmark results:

1

I highly recommend Wordpress on PHP 7. You will be amazed by the performance improvement and memory efficiency. Aaron Jorbin stated "2-3x speed improvement compared to PHP5.6".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.