ajax - Server cpu 100% usage and many php variables -
first of all, talking server host website.
so, noticed on cpanel specs minutes ago cpu usage 100% (i have range 80-95% ). on other hand, memory usage 5-10%.
i wondering if server crashed on future. e.g. cpu usage = 100% gonna happend? server may crash or not?
i notice cpu usage because running ajax script refresh div every 5 seconds. content of div string 3 random arrays created every 5 sec.
moreover, utilize many variables - arrays on code (php code) , wondering if must flush these variables. eg
<html> <? $variable1 == $variable2 == $variable3 == ?> </html> <? flush($variable1) ?>
is nessacary on php (like on c++ ) ? or php has auto garbage collector java?
edit: ajax scritp im using
index.html
<html> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script> <script type="text/javascript"> var auto_refresh = setinterval( function () { $('#autorefreshdiv').load('autorefreshdiv.php').fadein("slow"); }, 5000); // refresh every 5000 milliseconds </script> <body> <div id="autorefreshdiv"></div> </body> </html>
autorefreshdiv.php
<? $array1 = array("something1", "something2"); $array2 = array('something3','something4'); $array3 = array('something5','something6'); shuffle($array1); shuffle($array2); shuffle($array3); echo $array1[0].'.....'.$array3[0].'.....'.$array2[0] ; ?>
your question bit vague. answers: server not crash if cpu load reaches 100%. might respond slower crashing not option. might still want optimizing application...
flush has not much garbage collection output buffering. send info user before script done.
having many variables not such big problem if not talking many thousand. long have no mad recursion or such should safe. since memory @ 10% max, there's no danger there. of course of study php.ini limits total amount of memory script use.
i hope helps bit.
php ajax performance webserver
No comments:
Post a Comment