Improving mod_perl Driven Site's Performance -- Part IV: Sharing Memory Page 6
Download the authoritative guide: Data Center Guide: Optimizing Your Data Center Strategy
Download the authoritative guide: Cloud Computing: Using the Cloud for Competitive AdvantageI'm going to use the
Apache::Registryscript memuse.pl which consists of two parts: the first one preloads a bunch of modules (that most of them aren't going to be used), the second part reports the memory size and the shared memory size used by the single child process that I start. And of course it prints the difference between the two sizes.
memuse.pl --------- use strict; use CGI (); use DB_File (); use LWP::UserAgent (); use Storable (); use DBI (); use GTop ();
my = shift; ->send_http_header('text/plain'); my = GTop->new->proc_mem(20992); my = ->size; my = ->share; my = - ; printf "%10s %10s %10s\n", qw(Size Shared Difference); printf "%10d %10d %10d (bytes)\n",,,;
First I restart the server and execute this CGI script when none of the above modules preloaded. Here is the result:
Size Shared Diff 4706304 2134016 2572288 (bytes)
Now I take all the modules:
use strict; use CGI (); use DB_File (); use LWP::UserAgent (); use Storable (); use DBI (); use GTop ();
and copy them into the startup script, so they will get preloaded. The script remains unchanged. I restart the server and execute it again. I get the following.
Size Shared Diff 4710400 3997696 712704 (bytes)
Let's put the two results into one table:Preloading Size Shared Diff Yes 4710400 3997696 712704 (bytes) No 4706304 2134016 2572288 (bytes) -------------------------------------------- Difference 4096 1863680 -1859584
You can clearly see that when the modules weren't preloaded, the shared memory pages size were about 1864Kb smaller relative to the case where the modules were preloaded.
Assuming that you have had 256M dedicated to the web server, if you didn't preload the modules, you could have:268435456 = X * 2572288 + 2134016X = (268435456 - 2134016) / 2572288 = 103
Now let's calculate the same thing with modules preloaded:268435456 = X * 712704 + 3997696X = (268435456 - 3997696) / 712704 = 371
You can have almost 4 times more servers!!!
Remember that I have mentioned before that memory pages gets dirty and the size of the shared memory gets smaller with time? So I have presented the ideal case where the shared memory stays intact. Therefore the real numbers will be a little bit different, but not far from the numbers in our example.
Also it's obvious that in your case it's possible that the process size will be bigger and the shared memory will be smaller, since you will use different modules and a different code. So you won't get this fantastic ratio, but this example certainly helps to feel the difference.
- The mod_perl site's URL: http://perl.apache.org/
GToprelies in turn on libgtop library not available for all platforms; visit http://home-of-linux.org/gnome/libgtop/ for more information.
IT Solutions Builder TOP IT RESOURCES TO MOVE YOUR BUSINESS FORWARD
Which topic are you interested in?
What is your company size?
What is your job title?
What is your job function?
Searching our resource database to find your matches...