|
Posted by Jerry Stuckle on 01/07/08 12:46
Gilles Ganault wrote:
> On Sun, 06 Jan 2008 20:47:11 -0500, Jerry Stuckle
> <jstucklex@attglobal.net> 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@attglobal.net
==================
[Back to original message]
|