Optimizing PHP<>MySQL performance

Posted by BarsMonster on Server Fault See other posts from Server Fault or by BarsMonster
Published on 2010-04-10T06:05:43Z Indexed on 2010/04/10 6:13 UTC
Read the original article Hit count: 433

Filed under:
|
|
|

I am trying to optimize my PHP<>MySQL on this test script:

<?
  for($i=0;$i<100;$i++)//Itterations count
    $res.= var_dump(loadRow("select body_ru from articles where id>$i*50 limit 100"));

  print_r($res);
?>

I have APC, and article table have an index on id. Also, all these queries are hitting query cache, so sole MySQL performance if great.

But when I am using ab -c 10 -t 10 to bench this scipt, I am getting:

100 itterations: ~100req/sec (~10'000 MySQL queries per second)

5 itteration: ~200req/sec

1 itteration: ~380req/sec

0 itteration: ~580req/sec

I've tried to disable persistent connections in PHP - it made it slower a bit. So, how can I make it work faster, provided that MySQL is not limiting performance here?

© Server Fault or respective owner

Related posts about php

Related posts about mysql