Tham khảo tài liệu 'practical mod_perl-chapter 14:defensive measures for performance enhancement', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Page 508 Thursday November 18 2004 12 43 PM 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 will remember that the MaxRequestsPerChild directive allows you to specify the number of requests a child process should serve before it is killed. One way to limit the memory consumption of a process is to kill it and let Apache replace it with a newly started process which again will have most of its memory shared with the Apache parent. The new child process will then serve requests and eventually the cycle will be repeated. 508 Page 509