Re: Mod_Layout + PHP + a very large Ouput => Server unusable (Memory usage to high)

Alan Dennis Wright <[email protected]> Mon, 21 Jul 2008 09:01:17 +0100
Newsgroups gmane.comp.apache.mod-layout
Message-ID <AC8F160ECA13CA40A4F7F0FC32E02CB79D76A92706@MKT-MBX01.university.ds.derby.ac.uk>
Have you considered trying 'rlimitcpu' or 'rlimitmem' within you apache configuration?

I don't know if it'll work but its worth a try if it is apache that's causing the problem.  If php is inadvertantly causing the block then you'd need to adjust the php limits within php.ini (max_execution_time,max_input_time,memory_limit).

Rgds

Alan Wright
FEHS Technician

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Stefan
Sent: 20 July 2008 18:19
To: [email protected]; Alan Dennis Wright
Subject: [Mod_layout] Mod_Layout + PHP + a very large Ouput => Server unusable (Memory usage to high)

Hi,

My problem is the same like here: http://lists.tangent.org/pipermail/mod_layout/2008-February/002364.html

Can someone tell me, how to fix it? A little Script which kills Apache processes that need to much memory doesn't really work. When u have a PHP script, which runs in an endless loop and produces much conent (e.g. Errors) the Apache will "eat" all the memory (inc. swap) which makes your server nearly to stop working. If you have a bit luck you can login over ssh (5-10 Minutes till the loginscreen appeared) or you have to call the computer center and ask them to restart your server.

A script which causes such a usage could look like this (We have a Freehoster and there are always people that make such mistakes and we had it 3 times now :( )

<?php

$fh = fopen('test.txt', 'r');

while(!feof($fh))
    fgets($fh);

fclose($fh);

?>

If the file doesn't exists in addition to the wrong ! infront of feof() you will get an endless loop with uncountable error-messages ==> Apache needs all memory without ANY replace done by the Module.


Sorry for my bad english. I hope you understand, what i try to say and i hope, that it will and can be fixed.

Greets
Stefan Grubisic