[CCCPHP] lighttpd i PHP

1 view
Skip to first unread message

Àlex Corretgé

unread,
Apr 22, 2010, 12:42:29 PM4/22/10
to ccc...@googlegroups.com
Hola, estic fent proves de rendiment amb el lighttpd i per a servir arxius plans va com una bala, per a php també, però fent un Apache Benchmark he vist un problema:

This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking lab.peterpan (be patient).....done


Server Software:        lighttpd/1.4.19
Server Hostname:        lab.peterpan
Server Port:            80

Document Path:          /bench/
Document Length:        147 bytes

Concurrency Level:      5
Time taken for tests:   1.176 seconds
Complete requests:      100
Failed requests:        67
   (Connect: 0, Receive: 0, Length: 67, Exceptions: 0)
Write errors:           0
Total transferred:      32427 bytes
HTML transferred:       14743 bytes
Requests per second:    85.02 [#/sec] (mean)
Time per request:       58.809 [ms] (mean)
Time per request:       11.762 [ms] (mean, across all concurrent requests)
Transfer rate:          26.92 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:    21   58  32.2     50     144
Waiting:       19   44  26.4     38     119
Total:         21   58  32.2     50     144

Percentage of the requests served within a certain time (ms)
  50%     50
  66%     68
  75%     83
  80%     88
  90%    111
  95%    118
  98%    137
  99%    144
 100%    144 (longest request)

La configuració de fastcgi és aquesta
## Start an FastCGI server for php (needs the php5-cgi package)
## canviem max-procs de 2 a 50 i PHP_FCGI_CHILDRENS de 4 a 100
fastcgi.server    = ( ".php" =>
        ((
                "bin-path" => "/usr/bin/php-cgi",
                "socket" => "/tmp/php.socket",
                "max-procs" => 2,
                "idle-timeout" => 20,
                "bin-environment" => (
                        "PHP_FCGI_CHILDREN" => "40",
        8               "PHP_FCGI_MAX_REQUESTS" => "10000"
                ),
                "bin-copy-environment" => (
                        "PATH", "SHELL", "USER"
                ),
                "broken-scriptfilename" => "enable"
        ))
)

He canviat max-procs de 2 a 50 i PHP_FCGI_CHILDRENS de 4 a 100 però encara ha anat pitjor.

aquest script fa unes comparatives de benchmarking i triga una miqueta, però si faig la prova amb un senzill phpinfo() tinc 25 perdudes, però sicanvio idle-timeout a 33, llavors traga totes les del phpinfo, però tinc els mateixos errors en el de benchmark.

al final he deixat la configuració com a

                "max-procs" => 10,
                "idle-timeout" => 33,
                "bin-environment" => (
                        "PHP_FCGI_CHILDREN" => "10",
                        "PHP_FCGI_MAX_REQUESTS" => "500"
                ),

que he llegit que és el recomenable, però continuo amb més de 50 peticions fallades de 100!

I si faig ab -n 5 -c 1 també tinc moltes errades.

als logs no hi ha rés d'estrany.


bé, acabo de fer una prova, executar-ho desde l'Apache (mod_php i en un altre màquina) i obtinc menys errors que amb el lighttpd, però podria ser pq les peticions són més espaiades:

ping -c 3 netaccess.corretge.ct
PING netaccess.corretge.ct (10.10.10.22) 56(84) bytes of data.
64 bytes from 10.10.10.22: icmp_seq=1 ttl=64 time=0.098 ms
64 bytes from 10.10.10.22: icmp_seq=2 ttl=64 time=0.146 ms
64 bytes from 10.10.10.22: icmp_seq=3 ttl=64 time=0.156 ms

--- netaccess.corretge.ct ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 10026ms
rtt min/avg/max/mdev = 0.098/0.133/0.156/0.027 ms


ping -c 3 lab.peterpan
PING lab.peterpan (10.10.10.33) 56(84) bytes of data.
64 bytes from lab.peterpan (10.10.10.33): icmp_seq=1 ttl=64 time=0.022 ms
64 bytes from lab.peterpan (10.10.10.33): icmp_seq=2 ttl=64 time=0.024 ms
64 bytes from lab.peterpan (10.10.10.33): icmp_seq=3 ttl=64 time=0.014 ms

--- lab.peterpan ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1998ms
rtt min/avg/max/mdev = 0.014/0.020/0.024/0.004 ms



Per cert, executant l'script de benchmark, veig que és molt més efectiu el mod_php sobre Apache que el fast_cgi sobre lighttpd.

adjunto l'script executat i els resultats (el que fa és processar una array de 1000 elements cadascun amb una cadena de 512 posicions. La processo amb foerach i amb un for:

lighttpd (fast_cgi)

temps foreach -> 0.731945037842

temps for -> 1.25193595886

temps PARCIAL -> 24.8110294342

temps TOTAL -> 24.8379707336

Apache (mod_php)

temps foreach -> 0.389099121094

temps for -> 0.743865966797

temps PARCIAL -> 20.9720134735

temps TOTAL -> 20.9851264954

Si algú ha arribat fins aquí i fa servir el lighttpd, quina configuració empreu?


Atentament / Kind Regards

Àlex Corretgé
Serveis Informàtics Corretgé.com SLU

Carrer de la Font, 2
17142 - Verges
Tel: +34 972 780 422
Cell: +34 669 86 92 64

http://corretge.cat/

skype: corretge_com

LinkedIn: http://www.linkedin.com/in/corretge

News: http://bloc.corretge.cat

--
Rebeu aquest misatge pq esteu subscrits al Grup Google "CCCPHP - Consell PHP dels Països Catalans".
Per iniciar un debat, envieu un email a ccc...@googlegroups.com
Per esborrar-se del grup, envieu un email a cccphp-un...@googlegroups.com
Per a més opcions, visiteu aquest grup a http://groups-beta.google.com/group/cccphp?hl=ca
index.php

LLeïr Borràs

unread,
Apr 22, 2010, 1:38:24 PM4/22/10
to ccc...@googlegroups.com
Jo no he arribat a tant, he tontejat una mica, pero tb miraria nginx
--
Lleïr Borràs i Metje
http://lleirborras.blogspot.com
http://twitter.com/lleirborras
http://github.com/lleirborras

--
Rebeu aquest misatge pq esteu subscrits al Grup Google "CCCPHP - Consell PHP dels Països Catalans".
Per iniciar un debat, envieu un email a ccc...@googlegroups.com
Per esborrar-se del grup, envieu un email a cccphp-un...@googlegroups.com
Per a més opcions, visiteu aquest grup a http://groups-beta.google.com/group/cccphp?hl=ca

Subscription settings: http://groups.google.com/group/cccphp/subscribe?hl=ca
Reply all
Reply to author
Forward
0 new messages