You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by shawn <sh...@mbase.com> on 2005/02/02 04:35:10 UTC

Memory Question

Hi, I am sure this is a simple question but I just can't seem to find
any documentation that can tell me exactly what is wrong. The current
box I am running my apache 1.3.28 / Mod_perl server is a quad zeon 500
with 3GB of Ram, the server in general doesn't get all that many hits,
around 300,000 a day. Lately I have been seeing "server reached
MaxClients setting, consider raising the MaxClients setting" about 6
seconds after I start up apache. Then I added
 
#memory info
<Location /perl-status>
        PerlModule Apache::Status
        PerlModule B::TerseSize
        SetHandler perl-script
        PerlHandler Apache::Status
        PerlSetVar StatusTerse On
        PerlSetVar StatusTerseSize On
        PerlSetVar StatusTerseSizeMainSummary On
        PerlSetVar StatusDumper On
        PerlSetVar StatusPeek On
</Location>
 
and found the average site to be 37MB so I added 
 
PerlFixupHandler Apache::SizeLimit
$Apache::SizeLimit::MAX_UNSHARED_SIZE = 50000;
$Apache::SizeLimit::CHECK_EVERY_N_REQUESTS = 10;
 
 
Which I thought should cap it at 50MB so 3000 / 50 = 60 so I set
 
MinSpareServers 5
MaxSpareServers 10
StartServers 20
MaxClients 60
MaxRequestsPerChild 5000
 
Which in my mind should basically use up all 3GB of memory before I see
the "server reached MaxClients setting, consider raising the MaxClients
setting" but when the MaxClients error appears the memory is hardly
being used at all
 
Cat /proc/meminfo
MemTotal:      3116164 kB
MemFree:       1929260 kB
Buffers:         40656 kB
Cached:         127360 kB
SwapCached:      11028 kB
Active:        1094232 kB
Inactive:        49228 kB
HighTotal:     2228208 kB
HighFree:      1133632 kB
LowTotal:       887956 kB
LowFree:        795628 kB
SwapTotal:     1048536 kB
SwapFree:      1031008 kB
Dirty:             340 kB
Writeback:           0 kB
Mapped:         974096 kB
Slab:            29068 kB
Committed_AS:  1390760 kB
PageTables:       3156 kB
VmallocTotal:   114680 kB
VmallocUsed:       648 kB
VmallocChunk:   114032 kB
HugePages_Total:     0
HugePages_Free:      0
Hugepagesize:     4096 kB
 
Free -lm -s 3
                        total       used       free     shared
buffers     cached
Mem:                3043       1126       1916          0         39
124
Low:                 867         90        777          0          0
0
High:                 2175       1036       1139          0          0
0
-/+ buffers/cache:           961       2081
Swap:               1023         17       1006
 
Which I can't understand... Why is there free memory if the max clients
has already been reached? Shouldn't there be 3GB used or cached before
it wants more? Consequently the server is very up and down.. If anyone
could explain this to me I would greatly appreciate it.
 
Thanks
Shawn
 

Re: Memory Question

Posted by Stas Bekman <st...@stason.org>.
shawn wrote:
> Hi, I am sure this is a simple question but I just can’t seem to find 
> any documentation that can tell me exactly what is wrong. The current 
> box I am running my apache 1.3.28 / Mod_perl server is a quad zeon 500 
> with 3GB of Ram,

wow! I won't mind having one of those warming my room on the cold nights :)

> the server in general doesn’t get all that many hits, 
> around 300,000 a day. Lately I have been seeing “server reached 
> MaxClients setting, consider raising the MaxClients setting” about 6 
> seconds after I start up apache. Then I added
[....]
> and found the average site to be 37MB so I added
> 
> PerlFixupHandler Apache::SizeLimit
> 
> $Apache::SizeLimit::MAX_UNSHARED_SIZE = 50000;
> 
> $Apache::SizeLimit::CHECK_EVERY_N_REQUESTS = 10;

but it gets checked every 10 requests per process! So if you have 60 
processes. that means only on the 600th request it'll get checked. At 
least while debugging I'd check every request. But see below.

> Which I thought should cap it at 50MB so 3000 / 50 = 60 so I set

What this has to do with the memory limit? You hit the maxclients because 
Apache has spawned 60 clients, not because you run out of memory. That 
normally means that you either have 60 concurrent requests or you have 
some sort of run-away processes, which don't return to the pool of free 
servers.

I suggest that you install Apache::VMonitor and observe what exactly 
happens to your servers. Hint: it'll also show you the real memory usage, 
which you may have calculated incorrectly with other tools.

And you may want to review those chapters/sections:

http://modperlbook.org/html/ch10_01.html
http://modperlbook.org/html/ch11_01.html#pmodperl-CHP-11-SECT-1

-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com