Re: [PHP] Questions regarding limits of processes launched by system, exec, passthru ...

2008-09-28 Thread Bastien Koert
On Sat, Sep 27, 2008 at 12:50 PM, Richard Lynch [EMAIL PROTECTED] wrote:

 memory_limit and time_limit are implemented down in the guts of the PHP
 interpreter; They are not magic.

 They can't do diddly when PHP is running some other binary...
 
 From: Thodoris [EMAIL PROTECTED]
 Sent: Saturday, September 27, 2008 8:24 AM
 To: [EMAIL PROTECTED]; php-general@lists.php.net
 Subject: Re: [PHP] Questions regarding limits of processes launched by
 system, exec,passthru ...

  Hello all,
 
  Is there a way to limit the memory consumption and / or the CPU
  consumption of processes launched by the php functions system,
  exec, passthru, proc_open and shell_exec?
 
  We use mod_php with an apache (mpm-prefork) on Linux.
 
  The following settings don't have any effect at all:
  PHP:
max_execution_time 30
memory_limit 8M
  Apache:
RLimitCPU 30 30
RLimitMEM 8388608 8388608
 
  The limits above do have effect on php-scripts (without system calls)
  and on CGIs (as well on processes launched by CGIs).
 
  Any Ideas?
 
  Kind Regards
  valli
 
 
  PS: I tested it with the following two scripts:
  system_memorytest.php
  =
  html
  head
titlephp-systemcall-memory test/title
  /head
  body
php-systemcall-memory testbr
... and here's the system call:br
pre
  ?php
 $cmd = '/usr/bin/perl -e \'
$| = 1;
print start of the systemcallbr\n;
$s = teststr_;
while (1) {
   print len=.length($s).br\n;
   sleep(1);
   $s .= $s;
}
 \'';
 print htmlspecialchars($cmd);
  ?
/pre
  ?php
ob_flush();
flush();
system($cmd);
  ?
  /body
  /html
 
 
  system_timeouttest.php
  ==
  html
  head
titlephp-systemcall-timeout test/title
  /head
  body
php-systemcall-timeout testbr
... and here's the system call:br
pre
  ?php
 $cmd = '/usr/bin/perl -e \'
$| = 1;
print start of the systemcallbr\n;
$i = 0;
while (1) {
   if (($i % 1000) == 0) {
  print i=.$i.br\n;
   }
   $i += 1;
}
 \'';
 print htmlspecialchars($cmd);
  ?
/pre
  ?php
ob_flush();
flush();
system($cmd);
  ?
  /body
  /html
 
 
 
 
 

 Well as far as I know there are already memory limits to every php
 process and you define this in php.ini. I recently made a script that
 used to exhaust all the given memory and I needed to increase the limit.

 memory_limit = 16M

 You can change this to whatever you wish to control.  You can also
 change these if you want to control execution time:

 max_execution_time = 30 ; Maximum execution time of each script, in
 seconds
 max_input_time = 60 ; Maximum amount of time each script may spend
 parsing request data


 I haven't seen a way to control disk access space but I guess there are
 two ways to do that. One is quota the space that php writes in or do
 this by the programming way (meaning that you may check the space before
 you write something).

 As for the CPU I think there are OS specific techniques to control
 resource usage in general but it depends on what *nix system you use
 (FreeBSD, Linux etc).


 
 Thodoris

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


 ___

 The  information in this email or in any file attached
 hereto is intended only for the personal and confiden-
 tial  use  of  the individual or entity to which it is
 addressed and may contain information that is  propri-
 etary  and  confidential.  If you are not the intended
 recipient of this message you are hereby notified that
 any  review, dissemination, distribution or copying of
 this message is strictly prohibited.  This  communica-
 tion  is  for information purposes only and should not
 be regarded as an offer to sell or as  a  solicitation
 of an offer to buy any financial product. Email trans-
 mission cannot be guaranteed to be  secure  or  error-
 free. P6070214

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


Assuming a linux hosted server, see about getting a user created with ulimit
(which limits the resources on calls to system) if you can use that user

-- 

Bastien

Cat, the other other white meat


Re: [PHP] Questions regarding limits of processes launched by system, exec, passthru ...

2008-09-27 Thread Thodoris



Hello all,

Is there a way to limit the memory consumption and / or the CPU
consumption of processes launched by the php functions system,
exec, passthru, proc_open and shell_exec?

We use mod_php with an apache (mpm-prefork) on Linux.

The following settings don't have any effect at all:
PHP:
  max_execution_time 30
  memory_limit 8M
Apache:
  RLimitCPU 30 30
  RLimitMEM 8388608 8388608

The limits above do have effect on php-scripts (without system calls)
and on CGIs (as well on processes launched by CGIs).

Any Ideas?

Kind Regards
valli


PS: I tested it with the following two scripts:
system_memorytest.php
=
html
head
  titlephp-systemcall-memory test/title
/head
body
  php-systemcall-memory testbr
  ... and here's the system call:br
  pre
?php
   $cmd = '/usr/bin/perl -e \'
  $| = 1;
  print start of the systemcallbr\n;
  $s = teststr_;
  while (1) {
 print len=.length($s).br\n;
 sleep(1);
 $s .= $s;
  }
   \'';
   print htmlspecialchars($cmd);
?
  /pre
?php
  ob_flush();
  flush();
  system($cmd);
?
/body
/html


system_timeouttest.php
==
html
head
  titlephp-systemcall-timeout test/title
/head
body
  php-systemcall-timeout testbr
  ... and here's the system call:br
  pre
?php
   $cmd = '/usr/bin/perl -e \'
  $| = 1;
  print start of the systemcallbr\n;
  $i = 0;
  while (1) {
 if (($i % 1000) == 0) {
print i=.$i.br\n;
 }
 $i += 1;
  }
   \'';
   print htmlspecialchars($cmd);
?
  /pre
?php
  ob_flush();
  flush();
  system($cmd);
?
/body
/html




  


Well as far as I know there are already memory limits to every php 
process and you define this in php.ini. I recently made a script that 
used to exhaust all the given memory and I needed to increase the limit.


memory_limit = 16M

You can change this to whatever you wish to control.  You can also 
change these if you want to control execution time:


max_execution_time = 30 ; Maximum execution time of each script, in 
seconds
max_input_time = 60 ; Maximum amount of time each script may spend 
parsing request data



I haven't seen a way to control disk access space but I guess there are 
two ways to do that. One is quota the space that php writes in or do 
this by the programming way (meaning that you may check the space before 
you write something).


As for the CPU I think there are OS specific techniques to control 
resource usage in general but it depends on what *nix system you use 
(FreeBSD, Linux etc).




Thodoris

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Questions regarding limits of processes launched by system, exec, passthru ...

2008-09-27 Thread Thodoris

O/H Thodoris έγραψε:



Hello all,

Is there a way to limit the memory consumption and / or the CPU
consumption of processes launched by the php functions system,
exec, passthru, proc_open and shell_exec?

We use mod_php with an apache (mpm-prefork) on Linux.

The following settings don't have any effect at all:
PHP:
  max_execution_time 30
  memory_limit 8M
Apache:
  RLimitCPU 30 30
  RLimitMEM 8388608 8388608

The limits above do have effect on php-scripts (without system calls)
and on CGIs (as well on processes launched by CGIs).

Any Ideas?

Kind Regards
valli


PS: I tested it with the following two scripts:
system_memorytest.php
=
html
head
  titlephp-systemcall-memory test/title
/head
body
  php-systemcall-memory testbr
  ... and here's the system call:br
  pre
?php
   $cmd = '/usr/bin/perl -e \'
  $| = 1;
  print start of the systemcallbr\n;
  $s = teststr_;
  while (1) {
 print len=.length($s).br\n;
 sleep(1);
 $s .= $s;
  }
   \'';
   print htmlspecialchars($cmd);
?
  /pre
?php
  ob_flush();
  flush();
  system($cmd);
?
/body
/html


system_timeouttest.php
==
html
head
  titlephp-systemcall-timeout test/title
/head
body
  php-systemcall-timeout testbr
  ... and here's the system call:br
  pre
?php
   $cmd = '/usr/bin/perl -e \'
  $| = 1;
  print start of the systemcallbr\n;
  $i = 0;
  while (1) {
 if (($i % 1000) == 0) {
print i=.$i.br\n;
 }
 $i += 1;
  }
   \'';
   print htmlspecialchars($cmd);
?
  /pre
?php
  ob_flush();
  flush();
  system($cmd);
?
/body
/html




  


Well as far as I know there are already memory limits to every php 
process and you define this in php.ini. I recently made a script that 
used to exhaust all the given memory and I needed to increase the limit.


memory_limit = 16M

You can change this to whatever you wish to control.  You can also 
change these if you want to control execution time:


max_execution_time = 30 ; Maximum execution time of each script, 
in seconds
max_input_time = 60 ; Maximum amount of time each script may spend 
parsing request data



I haven't seen a way to control disk access space but I guess there 
are two ways to do that. One is quota the space that php writes in or 
do this by the programming way (meaning that you may check the space 
before you write something).


As for the CPU I think there are OS specific techniques to control 
resource usage in general but it depends on what *nix system you use 
(FreeBSD, Linux etc).




Thodoris



Sorry for the mistake I misread the original question.

The fact is that if I am correct when you call something using system a 
different process is handling this so you can do this only using the OS. 
In this case php.ini has no effect.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Questions regarding limits of processes launched by system, exec, passthru ...

2008-09-27 Thread Richard Lynch
memory_limit and time_limit are implemented down in the guts of the PHP 
interpreter; They are not magic.

They can't do diddly when PHP is running some other binary...

From: Thodoris [EMAIL PROTECTED]
Sent: Saturday, September 27, 2008 8:24 AM
To: [EMAIL PROTECTED]; php-general@lists.php.net
Subject: Re: [PHP] Questions regarding limits of processes launched by system, 
exec,passthru ...

 Hello all,

 Is there a way to limit the memory consumption and / or the CPU
 consumption of processes launched by the php functions system,
 exec, passthru, proc_open and shell_exec?

 We use mod_php with an apache (mpm-prefork) on Linux.

 The following settings don't have any effect at all:
 PHP:
   max_execution_time 30
   memory_limit 8M
 Apache:
   RLimitCPU 30 30
   RLimitMEM 8388608 8388608

 The limits above do have effect on php-scripts (without system calls)
 and on CGIs (as well on processes launched by CGIs).

 Any Ideas?

 Kind Regards
 valli


 PS: I tested it with the following two scripts:
 system_memorytest.php
 =
 html
 head
   titlephp-systemcall-memory test/title
 /head
 body
   php-systemcall-memory testbr
   ... and here's the system call:br
   pre
 ?php
$cmd = '/usr/bin/perl -e \'
   $| = 1;
   print start of the systemcallbr\n;
   $s = teststr_;
   while (1) {
  print len=.length($s).br\n;
  sleep(1);
  $s .= $s;
   }
\'';
print htmlspecialchars($cmd);
 ?
   /pre
 ?php
   ob_flush();
   flush();
   system($cmd);
 ?
 /body
 /html


 system_timeouttest.php
 ==
 html
 head
   titlephp-systemcall-timeout test/title
 /head
 body
   php-systemcall-timeout testbr
   ... and here's the system call:br
   pre
 ?php
$cmd = '/usr/bin/perl -e \'
   $| = 1;
   print start of the systemcallbr\n;
   $i = 0;
   while (1) {
  if (($i % 1000) == 0) {
 print i=.$i.br\n;
  }
  $i += 1;
   }
\'';
print htmlspecialchars($cmd);
 ?
   /pre
 ?php
   ob_flush();
   flush();
   system($cmd);
 ?
 /body
 /html






Well as far as I know there are already memory limits to every php
process and you define this in php.ini. I recently made a script that
used to exhaust all the given memory and I needed to increase the limit.

memory_limit = 16M

You can change this to whatever you wish to control.  You can also
change these if you want to control execution time:

max_execution_time = 30 ; Maximum execution time of each script, in
seconds
max_input_time = 60 ; Maximum amount of time each script may spend
parsing request data


I haven't seen a way to control disk access space but I guess there are
two ways to do that. One is quota the space that php writes in or do
this by the programming way (meaning that you may check the space before
you write something).

As for the CPU I think there are OS specific techniques to control
resource usage in general but it depends on what *nix system you use
(FreeBSD, Linux etc).



Thodoris

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


___

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Questions regarding limits of processes launched by system, exec, passthru ...

2008-09-25 Thread Valentin Schmid - ICSurselva AG
Hello all,

Is there a way to limit the memory consumption and / or the CPU
consumption of processes launched by the php functions system,
exec, passthru, proc_open and shell_exec?

We use mod_php with an apache (mpm-prefork) on Linux.

The following settings don't have any effect at all:
PHP:
  max_execution_time 30
  memory_limit 8M
Apache:
  RLimitCPU 30 30
  RLimitMEM 8388608 8388608

The limits above do have effect on php-scripts (without system calls)
and on CGIs (as well on processes launched by CGIs).

Any Ideas?

Kind Regards
valli


PS: I tested it with the following two scripts:
system_memorytest.php
=
html
head
  titlephp-systemcall-memory test/title
/head
body
  php-systemcall-memory testbr
  ... and here's the system call:br
  pre
?php
   $cmd = '/usr/bin/perl -e \'
  $| = 1;
  print start of the systemcallbr\n;
  $s = teststr_;
  while (1) {
 print len=.length($s).br\n;
 sleep(1);
 $s .= $s;
  }
   \'';
   print htmlspecialchars($cmd);
?
  /pre
?php
  ob_flush();
  flush();
  system($cmd);
?
/body
/html


system_timeouttest.php
==
html
head
  titlephp-systemcall-timeout test/title
/head
body
  php-systemcall-timeout testbr
  ... and here's the system call:br
  pre
?php
   $cmd = '/usr/bin/perl -e \'
  $| = 1;
  print start of the systemcallbr\n;
  $i = 0;
  while (1) {
 if (($i % 1000) == 0) {
print i=.$i.br\n;
 }
 $i += 1;
  }
   \'';
   print htmlspecialchars($cmd);
?
  /pre
?php
  ob_flush();
  flush();
  system($cmd);
?
/body
/html




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Questions regarding limits of processes launched by system, exec, passthru ...

2008-09-25 Thread Richard Lynch
 -Original Message-
 Is there a way to limit the memory consumption and / or the CPU
 consumption of processes launched by the php functions system,
 exec, passthru, proc_open and shell_exec?

I suspect...

PHP pretty much releases control to the shell or whatever, and just waits 
around for it to finish.

You'll have to put limits into the called processes, I think

I could be wrong.



___

The  information in this email or in any file attached
hereto is intended only for the personal and confiden-
tial  use  of  the individual or entity to which it is
addressed and may contain information that is  propri-
etary  and  confidential.  If you are not the intended
recipient of this message you are hereby notified that
any  review, dissemination, distribution or copying of
this message is strictly prohibited.  This  communica-
tion  is  for information purposes only and should not
be regarded as an offer to sell or as  a  solicitation
of an offer to buy any financial product. Email trans-
mission cannot be guaranteed to be  secure  or  error-
free. P6070214


Re: [PHP] Questions regarding limits of processes launched by system, exec, passthru ...

2008-09-25 Thread Daniel Brown
On Thu, Sep 25, 2008 at 4:28 AM, Valentin Schmid - ICSurselva AG
[EMAIL PROTECTED] wrote:
 Hello all,

 Is there a way to limit the memory consumption and / or the CPU
 consumption of processes launched by the php functions system,
 exec, passthru, proc_open and shell_exec?

Since you're working on a *NIX system, check out PHP's pcntl_*
functions[1] and the *NIX `nice` function[2].

1: http://www.php.net/manual/en/ref.pcntl.php
2: http://www.manpagez.com/man/1/nice/

-- 
/Daniel P. Brown
More full-root dedicated server packages:
Intel 2.4GHz/60GB/512MB/2TB $49.99/mo.
Intel 3.06GHz/80GB/1GB/2TB $59.99/mo.
Intel 2.4GHz/320/GB/1GB/3TB $74.99/mo.
Dedicated servers, VPS, and hosting from $2.50/mo.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php