Re: slowness mystery

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 4, 2008 at 8:45 AM, Rene Veerman <rene7705@xxxxxxxxx> wrote:
> Ok, i changed from reading from the database to reading from a file.
> It now clocks at 3.37seconds for the malignant peace of javascript..
> Still too slow :(
>
> Timing the readfile statement that outputs the cache file, is at 0.00109
> seconds according to a measurement done with microtime()
> It seems that this is not correct, because if i remove the readfile
> statement, things speed up to 120 milliseconds (from 3.37seconds)..



Make it write out a static .js file and link to that.  Apache can
serve up files like that way faster directly than piping it through
php.  If you don't want to go through that hassle, make sure you have
a far future expire header on the file so that the client does not
request it each time.


See look at this example script named testjs.php:
<?php
header("Content-Type: application/javascript");
readfile("yahoo-dom-event.js");
?>


Here is hitting the php script:
$ ab -n 500 -c 50 http://localhost/testjs/testjs.php

Document Path:          /testjs/testjs.php
Document Length:        31068 bytes

Concurrency Level:      50
Time taken for tests:   4.886 seconds
Complete requests:      500
Failed requests:        0
Broken pipe errors:     0
Total transferred:      15795390 bytes
HTML transferred:       15689340 bytes
Requests per second:    102.33 [#/sec] (mean)
Time per request:       488.60 [ms] (mean)
Time per request:       9.77 [ms] (mean, across all concurrent requests)
Transfer rate:          3232.79 [Kbytes/sec] received


Now hitting the JS directly:
$ ab -n 500 -c 50 http://localhost/testjs/yahoo-dom-event.js

Document Path:          /testjs/yahoo-dom-event.js
Document Length:        31068 bytes

Concurrency Level:      50
Time taken for tests:   0.925 seconds
Complete requests:      500
Failed requests:        0
Broken pipe errors:     0
Total transferred:      15992720 bytes
HTML transferred:       15831764 bytes
Requests per second:    540.54 [#/sec] (mean)
Time per request:       92.50 [ms] (mean)
Time per request:       1.85 [ms] (mean, across all concurrent requests)
Transfer rate:          17289.43 [Kbytes/sec] received


I could go from ~100 requests per second to ~500 requests per second
by hitting a js file directly.

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux