lighttpd forum lighty > What am I doing wrong?

Posted by Brian Moon
on 24.02.2006 17:49
The server is my test server which is a P3-650 with a U160 SCSI drive.

Hello World Benchmarks:

Server             Req/s
--------------------------
Apache+Static      866.54
lighttpd+Static    262.41

Apache+PHP+APC     454.70
lighttpd+PHP+APC   168.19


From everything I have read, this should not be the case.
Posted by Malte (Guest)
on 24.02.2006 19:40
Brian Moon wrote:
> The server is my test server which is a P3-650 with a U160 SCSI drive.
> 
> Hello World Benchmarks:
> 
> Server             Req/s
> --------------------------
> Apache+Static      866.54
> lighttpd+Static    262.41
> 
> Apache+PHP+APC     454.70
> lighttpd+PHP+APC   168.19
> 
> 
> From everything I have read, this should not be the case.

Two Things come to my mind when i see posts like this :

First :
For sure you're doing something terribly wrong. But are you really 
expecting other answers?
Second :
I don't think anybody could help you with that without any Information 
about your setup and your Test environment.

A little success - story :

Site : about 250-300 Mio PageImpressions per month
3 Servers  each:
Hardware : AMD3000+ @1Gb Ram + 160GbSata
Software : Debian apache 1.33 heavily tuned with php4.4.2 + 
eaccellerator0.9.4rc1 balanced with mod_backhand + wrrd -
 Mysql 4.1 master/slave replicated on all 3 Servers as backend
Caching : fragments where cached by Ea'shm

Load with apache between 10 - 60.

Then switched to lighttpd and Fastcgi -> Load drops immediately below 10 
and is now betwenn 0,X - 7 .

The Content of the site is some kind of Party Community with lots of 
pictures and a lot of php for all kind of Community functions such as 
messages and so on ( ~ 70 messages/s ) about 25000 pictures until now.




Posted by Brian Moon
on 25.02.2006 00:08
Because I am new to lighty, I did not want to assume what data one would 
need to answer my questions.  I can tell you that both apache and lighty 
were vanilla installs with little to no changes in the default configs.

> Load with apache between 10 - 60.
> 
> Then switched to lighttpd and Fastcgi -> Load drops immediately below 10 
> and is now betwenn 0,X - 7 .

I don't care about load, I care about speed.  If the load is .09 but I 
only get 100 req/s, it does me no good.  And, in fact, the load was not 
high at all during these tests.  But, neither was the performance.

I swear I am not trolling.  I want in on the secret to making it work.
on 25.02.2006 00:23
Brian Moon wrote:

> Hello World Benchmarks:

please post full ApacheBench output (if this is ApacheBench)
for these tests, for static use any static file, for dynamic
please try to use some _real_ application URL - even better
with SQL used, not just phpinfo() or Hello World etc.

it will be a good start for further research


Cheers,
---
Albatros Vep Taloha
http://host8.biz
Posted by Malte (Guest)
on 25.02.2006 21:07
Brian Moon wrote:
> 
> I don't care about load, I care about speed.  If the load is .09 but I 
> only get 100 req/s, it does me no good.  And, in fact, the load was not 
> high at all during these tests.  But, neither was the performance.
> 
I'd like you to know that each page consists of min. 15 files (pictures, 
css + 1 php)

so if you'd like to have plain hits/s (as what req/s are) we can 
calculate
250000000*15/30/24/3600 ~ 482,25req/s per Server (remember this value is 
on average)

To test by myself i went down and did it the same as you did (just for 
the sake of it)
lighttpd 1.4.10, php5.1 + eaccellerator (no i did not remove unnecessary 
modules)

ab -n10000 -c600 http://staging.XYZ.de/hello.php

Server Software:        lighttpd/1.4.10
Server Hostname:        staging.XYZ.de
Server Port:            80

Document Path:          /hello.php
Document Length:        11 bytes

Concurrency Level:      600
Time taken for tests:   10.928466 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      1561716 bytes
HTML transferred:       110121 bytes
Requests per second:    915.04 [#/sec] (mean)
Time per request:       655.708 [ms] (mean)
Time per request:       1.093 [ms] (mean, across all concurrent 
requests)
Transfer rate:          139.54 [Kbytes/sec] received

with -k

Server Software:        lighttpd/1.4.10
Server Hostname:        staging.XYZ.de
Server Port:            80

Document Path:          /hello.php
Document Length:        11 bytes

Concurrency Level:      600
Time taken for tests:   9.436407 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    10000
Total transferred:      1610322 bytes
HTML transferred:       110022 bytes
Requests per second:    1059.73 [#/sec] (mean)
Time per request:       566.184 [ms] (mean)
Time per request:       0.944 [ms] (mean, across all concurrent 
requests)
Transfer rate:          166.59 [Kbytes/sec] received



Server : Sempron64@3000+ 1GB Ram 100Mbit (linux  2.6.14.2)
Client : 2*AMD2400+ 1GB Ram 100Mbit (Linux  2.6.15.4)

Between Server and Client where 9 Hops (made through the internet) and 
latency 0f 8.92 ms (PING)

Some Important Parts of lighttpd config :
server.event-handler = "linux-sysepoll"
server.max-fds = 4096
server.max-keep-alive-requests = 100
server.max-keep-alive-idle = 6
server.max-read-idle = 30
server.max-write-idle = 120

fastcgi :
    "socket" => "/tmp/php-fastcgi.socket",
    "bin-path" => "/usr/bin/php5-cgi",
    "check-local" => "enable",
    "max-procs" => 20,
    "bin-environment" => (
            "PHP_FCGI_CHILDREN" => "15",
            "PHP_FCGI_MAX_REQUESTS" => "10000" ),
            "broken-scriptfilename" => "enable",
            "bin-copy-environment" => (
            "PATH", "SHELL", "USER" )

no access.log

=============apache 2.0.54========================

some words about apache2.0.54 config
(most of you know that apache2-mpm-worker isn't used together with php 
because gd is not threadsafe (afaik) )
so i used mpm-prefork + same php version & ini (PHP 5.1.2-1.dotdeb.2)
but as apache-module for sure

KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15

<IfModule prefork.c>
StartServers        50
MinSpareServers     10
MaxSpareServers     30
MaxClients          500
MaxRequestsPerChild 10000
</IfModule>

Maybe we can tweak another 100/reqs more per second with some better 
values these seemed to match this benchmark best (in my eyes)

again : ab -n10000 -c600 http://staging.XYZ.de/hello.php

Server Software:        Apache/2.0.54
Server Hostname:        staging.XYZ.de
Server Port:            80

Document Path:          /hello.php
Document Length:        11 bytes

Concurrency Level:      600
Time taken for tests:   36.823996 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      1730000 bytes
HTML transferred:       110000 bytes
Requests per second:    271.56 [#/sec] (mean)
Time per request:       2209.440 [ms] (mean)
Time per request:       3.682 [ms] (mean, across all concurrent 
requests)
Transfer rate:          45.87 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        8  538 2217.0      9   21013
Processing:    11  709 1825.6    154   27438
Waiting:        9  707 1825.6    152   27437
Total:         19 1247 3140.6    167   33505

-k

Server Software:        Apache/2.0.54
Server Hostname:        staging.XYZ.de
Server Port:            80

Document Path:          /hello.php
Document Length:        11 bytes

Concurrency Level:      600
Time taken for tests:   8.782287 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    9911
Total transferred:      2096224 bytes
HTML transferred:       110011 bytes
Requests per second:    1138.66 [#/sec] (mean)
Time per request:       526.937 [ms] (mean)
Time per request:       0.878 [ms] (mean, across all concurrent 
requests)
Transfer rate:          233.08 [Kbytes/sec] received


=> Hope i made no mistake and (i must admit) i was quite impressed about 
apache2 keepalive performance (i didn't expect something like this)
Posted by Brian Moon
on 26.02.2006 17:55
> please post full ApacheBench output (if this is ApacheBench)
> for these tests, for static use any static file, for dynamic
> please try to use some _real_ application URL - even better
> with SQL used, not just phpinfo() or Hello World etc.

Well, I am hesitant to use database activity in these tests the goal for 
this application will not use any database connectivity.  IMO, a hello 
world test is the proper baseline to use.  Can light get faster with a 
"real" application than it is for Hello World?

The primary use for the application will be to A) retrieve content from 
memcached and return it to the client and B) to serve static images.

I did do another test that involved memcached.  I don't have verbose 
data for it, but here is the summary:

Memcache 100 gets:

Platform         Req/s
----------------------
Apache+PHP+APC   62.40
lighttpd+PHP+APC 55.14

As you can see, Apache was still faster in that test.

I did do more verbose hello world and static file tests.  Rather than 
post the massive text here, I have put them here:

http://dev.phorum.org/lighty.txt
http://dev.phorum.org/apache.txt
http://dev.phorum.org/sysinfo.txt
http://dev.phorum.org/lighttpd.conf

I would really love to make this application go faster with lighty.  I 
just can't figure out what I am doing wrong.
on 26.02.2006 20:08
If you want to run ab with -c600 and not -c60, then:

1. turn off debugging (!)
2. test && check lighty error log
3. set server.max-fds = 8192
4. test && check lighty error log
5. set some nice values for:

    server.max-keep-alive-requests = value
    server.max-keep-alive-idle     = value
    server.max-read-idle           = value
    server.max-write-idle          = value

6. test && check lighty error log

now lighty should fly :-)


HTH
---
Albatros Vep Taloha
http://host8.biz
Posted by Brian Moon
on 27.02.2006 01:41
> 1. turn off debugging (!)

OMG, why would this be turned on in the example config that comes with 
the server?

> now lighty should fly :-)

Server             Req/s
--------------------------
Apache+Static      866.54
lighttpd+Static   1874.96

Apache+PHP+APC     454.70
lighttpd+PHP+APC   376.31

Full output: http://dev.phorum.org/lighty2.txt

Its definitely better on static pages, but still slower on PHP.  But, 
not by much. I am happy I was able to produce numbers closer to what I 
expected.  FYI, that is with 200 PHP fcgi children.  Apache has 
MaxClients at 150.

So, lastly, I decided to see if there was an advantage when outputting 
lots of data.  Our web pages can have as much as 100k of html in them.

Server             Req/s
--------------------------
Apache+PHP+APC     90.64
lighttpd+PHP+APC   60.59

Full output: http://dev.phorum.org/bigoutput.txt

Alas, that did not turn up any advantage either.  So, for static files, 
lighty is over twice as fast.
on 27.02.2006 10:53
Please try with fastcgi.server via socket, not host/port


HTH
---
Albatros Vep Taloha
http://host8.biz
Posted by Brian Moon
on 27.02.2006 15:08
Albatros Vep Taloha wrote:
> 
> Please try with fastcgi.server via socket, not host/port

Slowly but surely we are creating what should be, IMHO, the default 
config.

Server             Req/s
--------------------------
Apache+PHP+APC     444.29
lighttpd+PHP+APC  1022.45

I updated http://dev.phorum.org/lighty2.txt

I need one more magic bullet for big output though.

Server             Req/s
--------------------------
Apache+PHP+APC     90.64
lighttpd+PHP+APC   44.80

I updated http://dev.phorum.org/bigoutput.txt

Any more config tricks up your sleeve for making output faster?  I ran 
that last test 4 times and could not make it faster.  You will note, it 
actually got slower than the test where I used tcp for fcgi.
on 27.02.2006 18:01
It would be interesting to see your

   fastcgi.server = (...)

lighty config file part


---
Albatros Vep Taloha
http://www.host8.biz
Posted by Brian Moon
on 27.02.2006 18:05
config at http://dev.phorum.org/lighttpd.conf

php started like:

/usr/local/bin/spawn-fcgi -s /tmp/fgci-php.sock -f /usr/local/bin/php -u 
nobody -g nobody -C 200
on 27.02.2006 18:31
Since you are using fast-cgi on localhost,
and probably new PHP version, it is better
to not start separate PHP, so it can look like:

 fastcgi.server = ( ".php" => ((
       "bin-path" => "/usr/bin/php-cgi -c /usr/etc/php.ini",
       "socket" => "/tmp/php-fastcgi.sock-3-" + var.PID,
       "min-procs" => 1,
       "max-procs" => 3,
       "max-load-per-proc" => 3,
       "idle-timeout" => 60,
       "bin-environment" => (
          "PHP_FCGI_CHILDREN" => "50",
          "PHP_FCGI_MAX_REQUESTS" => "10000"
       ),
       "bin-copy-environment" => (
          "PATH", "SHELL", "USER"
       ),
       "broken-scriptfilename" => "enable"
 )))

now you can play with better values for 'max-procs'
and 'PHP_FCGI_CHILDREN' above (+/-)


try also with lighty config values as below:

  server.max-keep-alive-requests = 5
  server.max-keep-alive-idle = 5
  server.max-read-idle = 30
  server.max-write-idle = 120


HTH
---
Albatros Vep Taloha
http://www.host8.biz