Discussion in 'PHP' started by sofatime, Jun 19, 2007.

  1. sofatime

    sofatime Well-Known Member


    I am currently moving a website from Apache to Litespeed. Currently both sites are running, so I can easily compare the performance. These tests showed the following:
    - lsws total response times for php pages are much faster (sometimes twice as fast)
    - response times for static files like images and javascript are about the same

    But there is one thing I don't understand: the time for the first byte is much longer with lsws than with apache. lsws makes up for that easily in delivering the page faster, but I would like to know why that is. When surfing the pages you get the following impression:
    - apache: the page begins to render immediately but it takes quite long to complete
    - lsws: it takes some time until anything happens, but then it finishes real quick

    here is some test data (only html/php, no images, page from a PHP/MySQL-intensive CMS)

    total Response Time: 1.759 sec
    DNS: 0.238 sec
    Connect: 0.017 sec
    First byte: 1.194 sec
    Last byte: 0.309 sec

    total Response Time: 2.690 sec
    DNS: 0.317 sec
    Connect: 0.018 sec
    First byte: 0.390 sec
    Last byte: 1.964 sec

    Apache 1.3, PHP 4.4
    lsws 3.1.1, PHP 5.2.2 with APC (lsapi 4.0)

    It looks like lsws is waiting with sending the page out until it is complete and apache begins to send immediately.

    Can anyone explain this behaviour?

  2. mistwang

    mistwang LiteSpeed Staff

    Please double check if PHP output buffer is used for the LiteSpeed test.
  3. mistwang

    mistwang LiteSpeed Staff

    One flaw in your test is that, Apache is PHP 4.4, LiteSpeed is PHP 5.2.2, it is not an apple to apple comparison. According to our experiences, PHP 4 is faster than PHP 5.
  4. sofatime

    sofatime Well-Known Member

    You're right about not being a correct test (PHP4 and 5) and I am aware of that. I didn't know that PHP5 is slower.
    output_buffering is set to 8192 in php.ini. I also tried setting it to "On" and to 50000. Didn't change the behaviour.
    It's not that this is a real problem for me, as lsws is a lot faster anyway, I just would like to know why those two systems work different.
  5. mistwang

    mistwang LiteSpeed Staff

    You should turn off output_buffering if you want to avoid the delay of initial byte, or call flush() in your PHP code.
  6. sofatime

    sofatime Well-Known Member

    I tried output_buffering = 0 and output_buffering = Off, no change. I also tried the different settings of "Response Buffering" in lsws external application PHP, although that was already "No". Is there anything else I could have set wrong?

  7. PSS

    PSS Well-Known Member

    I have

    Response Buffering No
    Auto Start Yes
    Back Log 100
    Run On Start Up Yes

    which is pretty responsive (php5), but latency seems to be lowest when you disable PHP accelerators (I use APC). They put less stress on RAM and CPU, but also create latency. I'm a big low latency fan, even if the page loads bit slow it is the instant reaction to mouseclick what makes it FEEL fast.
  8. sofatime

    sofatime Well-Known Member

    Thanks for the info. I have the exact same settings. I also agree that most people think a server is fast if it answers immediately, even if the total loading time is longer. I have disabled APC for another reason (still fighting with occasional 503), but that didn't change anything about latency. It is clear to me that the CMS used is pretty slow, other applications on the same server are very fast, I just don't understand why on the apache installation with the same CMS sending of the page begins immediately.
  9. PSS

    PSS Well-Known Member

    I've spent countless hours on optimizing my PHP and MySQL apps, so I know there are tons of things you can do to make code run faster - too bad some developers do not take the time to do it. Litespeed is not the bottleneck.

Share This Page