Re: Reducing load for LAMP app?



Gilles Ganault wrote:
On Sun, 06 Jan 2008 20:47:11 -0500, Jerry Stuckle
<jstucklex@xxxxxxxxxxxxx> wrote:
The training E is not in the number - that's how very small floating point numbers are displayed.

I'll look at how to format the output of Microtime() so it's displayed
as seconds instead:

======
$start_time = microtime(true);
$end_time = microtime(true); $total_time = $end_time - $start_time;
print "Using microtime() as-is : $total_time<p>";

$starttimer = time()+microtime();
$stoptimer = time()+microtime();
$timer = round($stoptimer-$starttimer,4);
echo "Using Time + Microtime() : $timer";
======
Using microtime() as-is : 2.6941299438477E-5

Using Time + Microtime() : 0.2018
======


Which is incorrect.

2.6941299438477E-5 is standard scientific notation for display of very large or very small numbers. In this case, the actual value would be:

0.000026941299438477 seconds - about 27 microseconds.

Another point here is that floating point numbers have up to 15 significant digits (actual digits, not decimal places). When you add time() to it, you're adding 9 digits to the left - which only leaves you with six to the right of the decimal point.

So for several reasons your "fix" breaks more than it fixes.


The real question would be if this is normal, a peak - or
maybe a lull in the traffic. In the last case it could be a problem.

It's peak time. He had about 400 users logged on, with an unknown
number of guests lurking, which is the highest number he ever had.


OK, that's bad, but it's not as bad as if it were off-peak :-)

And yes, the CPU usage is high, but not necessarily that high.

The reason I thought it was a problem, is that this article on "top"
says that "load average" should not be much higher than 4, ie. 4 times
the amount of processes per processor (it's a single-CPU host):


YMMV. So that means you should only be running 4 processes. MySQL and Apache will each run more than that when they're not doing anything.

So you need to dig deeper. Most of your processes are sitting idle - and that 4:1 ratio could be valid for active tasks. Also, this can be affected by other problems - such as lack of memory slowing things down.

"The higher the number for load average, the more likely your system
is starting to suffer under an excessive load. As the saying goes,
your mileage may vary, but I tend to think of anything under four as
acceptable. Any higher and it starts feeling slow. I've seen systems
running around 15 to 20 and let me tell you, it's ugly."
http://www.linuxjournal.com/article/5309


Sure, and I've seen systems running around 15 to 20 and they've been doing fine. As he says - YMMV. It's only part of the equation. But it is something you need to include in the equation.

I'm really wondering if your host is trying to put too many people on your server. Monitoring the results of top over a period of time will help show you.

If it helps, it's very responsive with about 200 users logged on, but
it crawls to a halt with 400.


Yes, that definitely helps. What does top show when you've only got 200 users? It's the comparisons I look for, not actual numbers.

Generally speaking, and considering the number of web apps being
written these days, especially in LAMP, I'm surprised Google didn't
return an article on what to do to investigate a slow web application.

Thanks.


Yep, I agree.

But at this point it doesn't look like you've got a PHP problem. I'd suggest you follow up in the Linux admin groups - where the experts hang out. Most of us here know just enough Linux admin to get ourselves into trouble :-)

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================

.



Relevant Pages

  • Re: Display time and include milliseconds
    ... I am trying to display the current time including milliseconds (two digits only). ... http://us3.php.net/manual/en/function.microtime.php has many examples of how to use microtimeThis, with the DATEfunction may give you what you want.... ...
    (comp.lang.php)
  • Re: Cobol Myth Busters
    ... than just TRUNC (wich has 3 flavors on IBM zSeries). ... using 18 digits: packed decimal is 74% faster than binary ... packed decimal is 60% slower than binary ... DISPLAY compared to packed decimal ...
    (comp.lang.cobol)
  • Re: FPGA Journal Article
    ... 10 decimal digits fixed-point display, ... Above 1 MHz limited by time base accuracy, below 1 MHz by display ... but clutter up the design. ... A 20 times more accurate time base would cost <$20 extra. ...
    (comp.arch.fpga)
  • Re: Price Data Formatting
    ... When you load in a datafile of a stock or commodity, ... only 3 digits following the decimal rather than 4. ... So when I display prices in my application, I want to use the SAME format as ... It doesn't fit well in my textboxes for display. ...
    (microsoft.public.vb.general.discussion)
  • Re: HHC2007: HP Handhelds Conference in San Diego, CA on 29-30 September
    ... and displaying a long row of digits, turn down room lights ... until you can just still see the unlit "frame" around the display. ...
    (comp.sys.hp48)