Tuesday 01 March 2011 6:16:00 am
By : Gaetano Giunta
The amount of memory used by the application to render a single page is an important metric to be taken into account when sizing webservers to cope with the desired amount of traffic. In this installment, we explore memory usage by eZ Publish, in the context of a "webservice" page, ie. a page rendering a very simple piece of text in json format. We focus on an aspect outside control of the developer: php files with class definitions.
The rule of thumb, for a server dedicated to running only Apache, is to start with the installed memory, take away a fixed amount for the OS (eg. 500MB) and divide the rest for the number of concurrent webservers processes expected. For a 4GB server, with 100 processes, that means 35MB per process.
Do remember that if a php page consumes eg. 30MB, and the following requested page only 10MB, Apache will not release to the OS the extra 20MB until the process that served the 1st page is recycled.
This is a good reason for keeping an eye on the MaxRequestperChild parameter to keep your processes refreshing now and then (but not once per minute, or you'll slow don everything in process creation and killing). It is also an excellent reason to install a separate web application for serving static content (eg. nginx), even on the same server, and for doing proper usage of the caches in your eZ Publish applications. It might also be a good idea to have the editorail siteaccess on a separate server, since "editing" pages tend to chew up momery memory than "display" pages.
Even with the most advanced cache-block technique in place, the number of php classes used by eZ Publish to do its job is outside of the control of the developer. And every parsed php file chews up some memory. What I set out to do here is to measure the minimum number of php files that are loaded by the system, their size on disk, and the memory consumed by php for loading them.
A stripped-down eZ Publish 4.5beta1 install was measured:
This in order to obtain the lowest possible memory usage.
The autoload.php file was then patched to record the php files loaded and the memory used by php before and after the inclusion. Total memory at the end of script execution was not measured.
All tests were done on windows 32bit, with php 5.3.5. No opcode cache in use.