Memory Usage in PHP Frameworks

Posted by david on 16 June 2012 at 2:54 am

Just read this informative blog about PHP memory usage in some frameworks and CMS'. As of writing this blog, I have an HTML comment at the bottom of the page's HTML source that tells me the execution time and peak PHP memory usage to generate any page on this web site using ClayCMS. Just right-click and click View Source (or equivalent) to check it out (last thing on the page). 

I just checked the peak PHP memory usage for the home page of this site and it says Peak PHP Memory Usage 605660 bytes. We'll round that up to 606 KB. According to the blog post I linked to, PHP uses 256 KB just to render "Hello World" on a page. I'm sure that is dependent on the machine and how it is configured, but that sounds pretty accurate. I'm not trying to brag, I just want to point out that taking the time to optimize and focusing on performance does make a difference. Granted, there are a lot of features missing right now, like blocks and things like that. Check out the blog if you haven't yet. Those memory numbers were for a basic page, nothing extra. If I go to a page like that, maybe this page, it says Peak PHP Memory Usage 502292 bytes. So if we assume a decent sized application (this is a blog page with a pager, HTML filtering, and quite a bit of SQL data) load added 100 KB, adding blocks may add 200 to 300 KB to the memory usage, maybe more maybe less. We'll say it will add 400 KB. That puts ClayCMS' peak memory usage around 1 MB, with a full featured page being generated. 

I just hope I can keep this performance scale, because so far I'm cutting the best memory usage in half. Drupal with a limited number of modules was pulling down about 30 MB of memory at peak. Once again, I'm not bragging. I know how fast and easily something can get bloated. Let's just hope ClayCMS scales from here and keep trying to make it even better.


Log in to comment

No comments yet!