[PHP-DEV] PHP 4.0 Bug #10299 Updated: CPU and Memory Spike

2001-04-14 Thread goten

ID: 10299
User Update by: [EMAIL PROTECTED]
Status: Open
Bug Type: Performance problem
Description: CPU and Memory Spike

This is vmstat show if I keep reloading the script

procs  memory pagedisks faults  cpu
 r b w avm   fre  flt  re  pi  po  fr  sr da0 da1   in   sy  cs us sy id
 1 4 0   73860 134324   0   0   0   0   0   2   0  382 3804 258 16  1 83
 0 4 0   73860 134244   0   0   0   0   0   0   0  357 3789 245 15  4 81
 1 4 0   73860 134244   0   0   0   0   0   0   0  373 3763 263 14  3 83
 2 4 0   73860 13416  142   0   0   0 139   0   0   0  402 6155 285 26  4 70
 0 4 0   73860 134084   0   0   0   4   0  11   0  366 3179 220 11  2 87
 1 4 0   73860 134004   0   0   0   0   0   0   0  358 3943 257 15  3 82
 2 4 0   73860 134004   0   0   0   0   0   0   0  340 4201 240 12 42 45
 2 4 0   73860 134004   0   0   0   0   0   0   0  240 1842  90  0 100  0
 2 4 0   73116 134004   0   0   0   0   0  19   0  265 1802  98  0 100  0
 2 4 0   73116 134004   0   0   0   0   0   0   0  241 1753  93  0 100  0
 2 4 0   73116 134004   0   0   0   0   0   0   0  239 1729  96  0 100  0
 2 4 0   73116 134004   0   0   0   0   0   0   0  241 1612  94  0 100  0
 2 4 0   73116 134004   0   0   0   0   0   0   0  243 1576  97  0 100  0
 2 4 0   73116 134004   0   0   0   0   0   0   0  243 1541  98  0 100  0
 2 4 0   73116 134004   0   0   0   0   0   0   0  239 1487 102  0 100  0
 2 4 0   73116 134004   0   0   0   0   0   0   0  241 1401  93  0 100  0
 2 4 0   73116 134004   0   0   0   0   0   0   0  251 1405 100  0 100  0
 2 4 0   73116 134004   0   0   0   0   0   0   0  246 1338 101  0 100  0
 2 4 0   73116 134004   0   0   0   0   0   0   0  238 1297  94  0 100  0
 2 4 0   73860 134004   0   0   0   0   0   0   2  243 1282 100  0 100  0
 2 4 0   73860 134004   0   0   0   0   0   0   0  239 1223  89  0 100  0
 2 4 0   73860 134004   0   0   0   2   0   9  16  300 1180  92  0 100  0
 procs  memory pagedisks faults  cpu
 r b w avm   fre  flt  re  pi  po  fr  sr da0 da1   in   sy  cs us sy id
 3 4 0   73860 134004   0   0   0   0   0   0   0  251 1156  90  0 100  0
 3 4 0   50296 134004   0   0   0   0   0   6   0  258 1116  93  0 100  0
 2 4 0   50296 134004   0   0   0   0   0   0   0  240 1108  83  0 100  0
 3 4 0   50296 134004   0   0   0   0   0   0   0  245 1064  92  0 100  0
 3 4 0   46988 134004   0   0   0   0   0   0   0  242 1031  83  0 100  0
 3 4 0   46988 134004   0   0   0   0   0   0   0  242  989  82  0 100  0
 2 4 0   46988 134004   0   0   0   0   0   0   0  243 1010  85  0 100  0
 2 4 0   46988 134004   0   0   0   0   0   1   0  241  985  81  0 100  0
 2 4 0   46988 134004   0   0   0   0   0   0   0  241  971  89  1 99  0
 2 4 0   46988 134004   0   0   0   0   0   0   0  243  940  74  0 100  0
 3 4 0   46988 134004   0   0   0   2   0   8   0  250  926  80  0 100  0
 2 4 0   46988 134004   0   0   0   0   0   1   0  245  930  88  0 100  0
 3 4 0   46988 134004   0   0   0   0   0   0   0  240  905  80  0 100  0
 2 4 0   46988 134004   0   0   0   0   0   7   0  253  920 100  0 98  2
 3 4 0   47332 13056   90   0   0   0   0   0   0   0  239 2113 116  3 97  0
 2 4 0   46588 130484   0   0   0   0   0   1   0  243 2334 103  1 99  0
 1 4 0   46244 133924   0   0   0  86   0   8   0  276 4383 140  7 19 74
 1 4 0   47896 13184   59   0   0   0   0   0   2   0  275  621  56  7  1 92
 0 4 0   47896 13152   20   0   0   0   0   0   1   0  253  471  46  6  1 93
 1 4 0   47492 13372   18   0   0   0  64   0   0   0  251  478  43  0  1 99
 0 4 0   47492 133724   0   0   0   0   0   0   0  235  440  40  0  0 100
 0 4 0   47492 133724   0   0   0   0   0   0   0  238  442  40  0  2 98

The CPU time drop from 80 all the way to zero and make the Apache hang for like 30 
seconds and the resume back again.  It happens VERY often if I only have like 30 users 
surf the website at the same time.  It pretty much bring the web server down if I have 
around 50 users surft the site

Previous Comments:
---

[2001-04-11 18:03:59] [EMAIL PROTECTED]
I am running on FreeBSD 4.2 Stable, Apache 1.3.19 + PHP 4.0.4pl1 + Modssl on a Dual P2 
400mhz with 256mb ram.  From time to time, one of the httpd process will eat up all 
the CPU time and memory, and after around 5 to 10 seconds, it goes back to normal  
Even a Very simple script like

? 
echo "test";
?

can make it happen. 1 out of 25 reload of the above script can make the spike happen.  
But the web server do not crash though.  If I run on a script with heavy database 
access, it happen 1 out of 10 if I press reload button continously.

BTW, is that normal for Apache to take up 30% of the CPU time to excute 

[PHP-DEV] PHP 4.0 Bug #10299 Updated: CPU and Memory Spike

2001-04-14 Thread goten

ID: 10299
User Update by: [EMAIL PROTECTED]
Status: Open
Bug Type: Performance problem
Description: CPU and Memory Spike

I found the problem.  since the script I use have a lot of include and require 
statement.  just a script include a bunch of files and keep reloading the page will 
kill the server in no time.  I attach a sample config file I usually include, just 
make a test.php and include this file like 10 times to simulate a lot of include 
files.  And then, just keep reloading test.php.  You should see the script take a lot 
of CPU time and eventually the httpd eat all the CPU time and the process hang.  From 
command "top", one of the httpd process keep eating up CPU time.

The following is the sample config file 

?

/*Root directory */
$config[root_path] = "/usr2/home/business/test/www";
$config[w3b_path] = "/usr2/home/business/test/www/wwwthreads";
$config[data_path] = "/usr2/home/business/test/data";
$config[rdf_path] = "/usr2/home/business/test/www/rdf";


/* database */

include $config[root_path]."/db.php";

/* global */
$config[sitename] = "www.test.net"; 
$config[root_url] = "http://www.test.net/";


// Cookie Setting
$config[cookie_path]  = "/"; # web root directory 
$config[CookieURL] = ".test.net";
$config[cookieTTL] = 7200; // in seconds


$config[minpass]= 3;  # Minimum user password length in characters



/* language and locale */
$config[language]   = "english";# [english] english, [big5] BIG5 code


$config[locale] = "english";# Used for translation of date-related stuff

/* story control */
$config[commentmax] = 4096;
$config[abstractlen]= 4996; #length of abstract show on first page

$config[icon_width] = 100; # Topic icons width
$config[timezone] = "HKT";  #Time zone


$config[limitnews]  = 10;   # default number of stories per page
$config[older_story_num]= 10;   # number of older stories to display

$config[anon_users] = 0; # 1 to allow anonymous postings
 # 0 to disable


/* theme control */

$config[def_theme]  = "Main"; # name of default theme (see themes/ directory for 
list)

/* mail settings */
$config[use_fake_email] = 1; # Displays fake email addresses for users instead of the 
real ones

$config[notifyEmail]= "[EMAIL PROTECTED]"; #address where you want to 
receive notice


//$config[CensorList]   = 
array('fuck','cunt','fucker','fucking','pussy','cock','c0ck','cum','bitch','shit');
$config[CensorList] = array("/fuck/s","/fuck/s","/fuck/s",
"/[a-z]*fuck[a-z]*/is",
"/[a-z]*cunt[a-z]*/is",
"/[a-z]*pussy[a-z]*/is",
"/[a-z]*cock[a-z]*/is",
"/[a-z]*c0ck[a-z]*/is",
"/[a-z]*shit[a-z]*/is",
"/[a-z]*bitch[a-z]*/is",
"/[a-z]*diu[a-z]*/is"
);
# See also specific LOCALE definitions

$config[CensorMode]   = 3;  # 0: no filtering
# 1: exact match
# 2: match word beginnings
# 3: match string anywhere in words
$config[CensorReplace]   =  "[CENSORED]" ;

/* allowable HTML tags. Used by check_html()
   Happily lifted (with mods) from phpslash */
$config[AllowableHTML] = array("p"=1,   # 2 means accept all qualifiers: foo bar
  "b"=1,# 1 means accept the tag only: foo
  "i"=1,
  "a"=2,
  "em"=1,
  "br"=1,
  "strong"=1,
  "blockquote"=1,
  "img"=2,
  "tt"=1,
  "hr"=1,
  "li"=1,
  "ol"=1,
  "div"=1,
  "ul"=1);

$config[AllowableHTMLtag] = 
"b,i,a,em,br,strong,blockquote,tt,hr,li,ol,div,ul";


/* poll settings */

$config[maxOptions] = 12;   # maximal number of options allowed
$config[BarScale]   = 1;# scale of result bar (in multiples of 100 pixels)

$config[warnCheaters]   = 1;# 1 - a notice issued on vote second try
# 0 - silently ignores the vote

$config[maxOptions] = 10;


/* story stuff */

$reasons = array('As is',   # "Normal"
'Offtopic', # Bad Responses
'Flamebait',
'Troll',
'Redundant',
'Insightful',   # Good Responses
'Interesting',
'Informative',
'Funny',
'Overrated',# Last two are "special"
'Underrated');



if ($config[dateString] ==