You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Mark Maunder <ma...@ziptree.com> on 2004/02/29 11:53:36 UTC

[OT] Forcing httpd's to not swap out of memory

Is there a way to force apache to stay in memory. My linux box swaps
children out (shown in brackets in ps) during long periods of low
activity, and swapping them back in is causing latency for my users.

Thanks,

Mark.


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: [OT] Forcing httpd's to not swap out of memory

Posted by Stas Bekman <st...@stason.org>.
Mark Maunder wrote:
> Is there a way to force apache to stay in memory. My linux box swaps
> children out (shown in brackets in ps) during long periods of low
> activity, and swapping them back in is causing latency for my users.

Take a look at these threads, which discuss this exact topic:
http://marc.theaimsgroup.com/?t=101682066500004&r=1&w=2
http://marc.theaimsgroup.com/?l=apache-modperl&m=101667859909389&w=2
http://marc.theaimsgroup.com/?t=99356839200003&r=1&w=2

If someone could summarize those to be put in the docs that would be very 
useful for others in the same need.

__________________________________________________________________
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

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: [OT] Forcing httpd's to not swap out of memory

Posted by "Randal L. Schwartz" <me...@stonehenge.com>.
>>>>> "Mark" == Mark Maunder <ma...@ziptree.com> writes:

Mark> Is there a way to force apache to stay in memory. My linux box swaps
Mark> children out (shown in brackets in ps) during long periods of low
Mark> activity, and swapping them back in is causing latency for my users.

Post a URL for your box on a file-swapping or pr0n site.  That'll ensure
a continuous stream of hits.

:-)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<me...@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: [OT] Forcing httpd's to not swap out of memory

Posted by Ged Haywood <ge...@jubileegroup.co.uk>.
Hi there,

On Mon, 1 Mar 2004, Mark Maunder wrote:

> is anyone using the 2.6 kernel on live servers yet?

Nearly did it, then I ran into problems with a VPN which only happen
with the 2.6 kernel.  Given the networking nature of the problems I
thought better of it.  This was with 2.6.x where x <= 1 so YMMV.

73,
Ged.


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: [OT] Forcing httpd's to not swap out of memory

Posted by Mark Maunder <ma...@ziptree.com>.
Thanks. I think the idea of sending a useless signal is the best so far.
I'm also going to upgrade my kernel and see if I can get more meaningful
output from ps.

btw, is anyone using the 2.6 kernel on live servers yet?

On Sun, 2004-02-29 at 12:50, Render Web wrote:
> Mark Maunder wrote:
> > I've considered it, but I have a few other processes that I'd like to
> > swap out when they're inactive to increase disk cache etc. btw, I've
> > managed to lock mysql into memory on the server using the memlock config
> > option which uses mlockall. I've googled myself to death but can't find
> > anything about mlock and apache.
> 
> altavista gave me this
> 
> http://www.itworld.com/nl/lnx_tip/05182001/
> 
> I have not tried it but one trick would be to create
> a process that locks memeory then execs apache into the alloced
> memory space. Somehow I hope/doubt this would not work but i
> may be worth a try as a "workaround" :-)
> 
> A quick grep of the most recent (cvs update as of 29/feb 12:43)
> apache2/mp2 source shows no ocurrences of 'mlock'.
> 
> Note that it should not be too difficult to add however
> it would make more sense to upgrade apache to a RT process
> if this is your objective.
> 
> Another option would be to install an SSD as swap device.
> This does make linux (and Cray's) go like greased weasel stuff
> and as memory costs are low, should not be an expensive option.
> 
> Whatever you decide to do , keep us informed- I for one am
> interested in how you solve the problem as I would with
> large AP2/MP2 apps and swap can be a problem for me as well.
> 
> Jacqui
> 


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: [OT] Forcing httpd's to not swap out of memory

Posted by Render Web <re...@ntlworld.com>.
Mark Maunder wrote:
> I've considered it, but I have a few other processes that I'd like to
> swap out when they're inactive to increase disk cache etc. btw, I've
> managed to lock mysql into memory on the server using the memlock config
> option which uses mlockall. I've googled myself to death but can't find
> anything about mlock and apache.

altavista gave me this

http://www.itworld.com/nl/lnx_tip/05182001/

I have not tried it but one trick would be to create
a process that locks memeory then execs apache into the alloced
memory space. Somehow I hope/doubt this would not work but i
may be worth a try as a "workaround" :-)

A quick grep of the most recent (cvs update as of 29/feb 12:43)
apache2/mp2 source shows no ocurrences of 'mlock'.

Note that it should not be too difficult to add however
it would make more sense to upgrade apache to a RT process
if this is your objective.

Another option would be to install an SSD as swap device.
This does make linux (and Cray's) go like greased weasel stuff
and as memory costs are low, should not be an expensive option.

Whatever you decide to do , keep us informed- I for one am
interested in how you solve the problem as I would with
large AP2/MP2 apps and swap can be a problem for me as well.

Jacqui


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: [OT] Forcing httpd's to not swap out of memory

Posted by "Charles C. Fu" <pe...@mail.web-i18n.net>.
In <10...@beast> on 29 Feb 2004,
   Mark Maunder <ma...@ziptree.com> wrote:
> I'm assuming the httpd processes are in swap, because according to
> the ps docs, processes surrounded by [square brackets] are swapped
> out. But I think ps might be lying because as soon as I start
> apache, the processes appear as [httpd], and even if I blast the
> server, they stay []'d.

What it really means is that the command line arguments have been lost
by the kernel.  In reality, Linux almost never swaps out processes
(although it does page parts of them out), and you can see from the
resident size column that your httpd processes aren't swapped out,
either.  You can monitor how many pages have been paged out using gtop
or the oldps(1) command (use the 'm' argument for memory info) that is
part of some procps packages.

As for why your kernel is losing the command line arguments, that was
a behavior peculiar to some Linux kernels (in particular, mid-range
2.4.x kernels).  If you upgrade to a newer 2.4.x kernel or downgrade
to an older one, that behavior should go away.

None of this addresses your original question of how to prevent the
swapping/paging, of course, but gtop and oldps should allow you to
verify if the solution you implement is working.

-ccwf
-- 
Charles C. Fu                           ,--
Founder                ___  __ __. . ,-/--
Web i18n, LLC              (_,(_,|/|/ /
www.web-i18n.net                 ----'

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: [OT] Forcing httpd's to not swap out of memory

Posted by Martin Langhoff <ml...@nzl.com.ar>.
Mark Maunder wrote:
> 
> Definitely an option. I could blast the server with ap every 10 minutes.
> But it's not too elegant in that not all apache children are guaranteed
> to serve requests, so some will stay in swap.

Why not send them a meaningless signal? It'd force the kernel to bring 
them back to 'handle' the signal, and then they'd ignore it. You get all 
the children, it's simpler and doesn't muck up you logs or request counts.

Untested cron entry:
*/10 * * * * ps -u apache --option-show-only-pids | xargs kill -SIGARLM

cheers,





martin
-- 
--
Martin Langhoff |||| http://nzl.com.ar/



-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: [OT] Forcing httpd's to not swap out of memory

Posted by Ged Haywood <ge...@jubileegroup.co.uk>.
Hello again,

On Sun, 29 Feb 2004, Mark Maunder wrote:

> I could blast the server with ap every 10 minutes.

Or every 10 seconds.

> But it's not too elegant in that not all apache children are guaranteed
> to serve requests, so some will stay in swap.

They will if you make them die after serving say 100 requests.

> I think ps might be lying

Well I don't think it will be lying, but it might be misleading.
Have you looked at the mod_perl documentation?

http://perl.apache.org/docs/1.0/guide/performance.html

73,
Ged.

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: [OT] Forcing httpd's to not swap out of memory

Posted by Mark Maunder <ma...@ziptree.com>.

On Sun, 2004-02-29 at 12:43, Ged Haywood wrote:
> If I read you right, this only happens when your Apache processes are
> inactive for some time.  So why not set up a process which keeps them
> active, like a kind of watchdog?  It would be very simple using LWP or
> something like that.

Definitely an option. I could blast the server with ap every 10 minutes.
But it's not too elegant in that not all apache children are guaranteed
to serve requests, so some will stay in swap.

I've been doing a bit more testing actually, and I have to be honest
with you here. I'm assuming the httpd processes are in swap, because
according to the ps docs, processes surrounded by [square brackets] are
swapped out. But I think ps might be lying because as soon as I start
apache, the processes appear as [httpd], and even if I blast the server,
they stay []'d. 

Here's what I'm seeing:
root     29307  0.0  3.4 24028 17332 ?       S    10:51   0:01
/usr/local/apache/bin/httpd
nobody   29309  0.0  3.7 25212 18724 ?       S    10:51   0:00 [httpd]
nobody   29310  0.0  3.9 27260 20228 ?       S    10:51   0:02 [httpd]
nobody   29311  0.0  4.7 31964 23964 ?       S    10:51   0:04 [httpd]
nobody   29312  0.0  4.5 30872 23184 ?       S    10:51   0:04 [httpd]
nobody   29314  0.0  3.7 25388 18896 ?       S    10:51   0:00 [httpd]
nobody   29315  0.0  4.0 27244 20368 ?       S    10:51   0:01 [httpd]
nobody   29316  0.0  3.5 24416 17760 ?       S    10:51   0:00 [httpd]
nobody   29317  0.0  4.2 28476 21544 ?       S    10:51   0:03 [httpd]
nobody   29318  0.0  4.3 28924 22012 ?       S    10:51   0:04 [httpd]
nobody   29324  0.0  3.4 24368 17652 ?       S    10:51   0:00 [httpd]
nobody   29335  0.0  4.1 27744 20824 ?       S    10:56   0:01 [httpd]
nobody   29339  0.0  3.5 24464 17932 ?       S    10:56   0:00 [httpd]

notice the parent httpd process isn't surrounded by []. 


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: [OT] Forcing httpd's to not swap out of memory

Posted by Ged Haywood <ge...@jubileegroup.co.uk>.
Hello again,

On Sun, 29 Feb 2004, Mark Maunder wrote:

> > Don't mount the swap space?

> I've considered it, but I have a few other processes that I'd like to
> swap out

If I read you right, this only happens when your Apache processes are
inactive for some time.  So why not set up a process which keeps them
active, like a kind of watchdog?  It would be very simple using LWP or
something like that.

73,
Ged.

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: [OT] Forcing httpd's to not swap out of memory

Posted by Mark Maunder <ma...@ziptree.com>.
I've considered it, but I have a few other processes that I'd like to
swap out when they're inactive to increase disk cache etc. btw, I've
managed to lock mysql into memory on the server using the memlock config
option which uses mlockall. I've googled myself to death but can't find
anything about mlock and apache.

On Sun, 2004-02-29 at 11:33, Ged Haywood wrote:
> Hi there,
> 
> On Sun, 29 Feb 2004, Mark Maunder wrote:
> 
> > Is there a way to force apache to stay in memory.
> 
> Don't mount the swap space?
> 
> 73,
> Ged.


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: [OT] Forcing httpd's to not swap out of memory

Posted by Ged Haywood <ge...@jubileegroup.co.uk>.
Hi there,

On Sun, 29 Feb 2004, Mark Maunder wrote:

> Is there a way to force apache to stay in memory.

Don't mount the swap space?

73,
Ged.

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html