Chapter 14. Defensive Measures for Performance Enhancement
If you have already worked with mod_perl, you have probably noticed that it can be difficult to keep your mod_perl processes from using a lot of memory. The less memory you have, the fewer processes you can run and the worse your server will perform, especially under a heavy load. This chapter presents several common situations that can lead to unnecessary consumption of RAM, together with preventive measures.
Controlling Your Memory Usage
When you need to control the size of your httpd
processes, use one of the two modules,
Apache::GTopLimit and
Apache::SizeLimit, which kill Apache
httpd processes when those processes grow too
large or lose a big chunk
of their shared memory. The two modules
differ in their methods for finding out the memory usage.
Apache::GTopLimit relies on the
libgtop library to perform this task, so if this
library can be built on your platform you can use this module.
Apache::SizeLimit includes different methods for
different platforms—you will have to check the
module’s manpage to figure out which platforms are
supported.
Defining the Minimum Shared Memory Size Threshold
As we have already discussed, when it is first created, an Apache child process usually has a large fraction of its memory shared with its parent. During the child process’s life some of its data structures are modified and a part of its memory becomes unshared (pages become “dirty”), leading to an increase in memory consumption. You ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access