PHP vs web.py (cgi) vs python cgi en dreamhost
estoy indeciso sobre que usar para un proyectito web que tengo en mente, el hosting es dreamhost, y debido a que tiene la limitacion de 100MB de RAM por proceso python en fastcgi (cosa que no tiene ruby on rails :S), decidi probar las alternativas.
probe un hola mundo en PHP, web.py y un script de python pelado.
tanto web.py y el script son servidos por un apache con mod_rewrite, todos hacen lo mismo, que es imprimir "hola mundo!", los resultados son los siguientes:
para php
ab -c 4 -n 300 http://www.marianoguerra.com.ar/php/
This is ApacheBench, Version 2.3
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking www.marianoguerra.com.ar (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Finished 300 requests
Server Software: Apache/2.2.9
Server Hostname: www.marianoguerra.com.ar
Server Port: 80
Document Path: /php/
Document Length: 12 bytes
Concurrency Level: 4
Time taken for tests: 28.272 seconds
Complete requests: 300
Failed requests: 0
Write errors: 0
Total transferred: 72980 bytes
HTML transferred: 3600 bytes
Requests per second: 10.61 [#/sec] (mean)
Time per request: 376.961 [ms] (mean)
Time per request: 94.240 [ms] (mean, across all concurrent requests)
Transfer rate: 2.52 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 24 33 10.1 30 93
Processing: 272 342 91.5 315 929
Waiting: 267 334 90.4 308 913
Total: 298 375 93.3 347 976
Percentage of the requests served within a certain time (ms)
50% 347
66% 365
75% 387
80% 398
90% 446
95% 562
98% 738
99% 844
100% 976 (longest request)
para web.py
ab -c 4 -n 300 http://www.marianoguerra.com.ar/py/
This is ApacheBench, Version 2.3
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking www.marianoguerra.com.ar (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Finished 300 requests
Server Software: Apache/2.2.9
Server Hostname: www.marianoguerra.com.ar
Server Port: 80
Document Path: /py/
Document Length: 13 bytes
Concurrency Level: 4
Time taken for tests: 84.578 seconds
Complete requests: 300
Failed requests: 0
Write errors: 0
Total transferred: 65100 bytes
HTML transferred: 3900 bytes
Requests per second: 3.55 [#/sec] (mean)
Time per request: 1127.711 [ms] (mean)
Time per request: 281.928 [ms] (mean, across all concurrent requests)
Transfer rate: 0.75 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 24 32 7.1 30 89
Processing: 423 1095 485.1 981 2824
Waiting: 422 1094 485.1 980 2821
Total: 454 1127 484.6 1012 2851
Percentage of the requests served within a certain time (ms)
50% 1012
66% 1222
75% 1375
80% 1483
90% 1829
95% 2212
98% 2481
99% 2660
100% 2851 (longest request)
para python cgi
ab -c 4 -n 300 http://www.marianoguerra.com.ar/picgi/
This is ApacheBench, Version 2.3
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking www.marianoguerra.com.ar (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Finished 300 requests
Server Software: Apache/2.2.9
Server Hostname: www.marianoguerra.com.ar
Server Port: 80
Document Path: /picgi/
Document Length: 323 bytes
Concurrency Level: 4
Time taken for tests: 19.617 seconds
Complete requests: 300
Failed requests: 0
Write errors: 0
Non-2xx responses: 300
Total transferred: 173100 bytes
HTML transferred: 96900 bytes
Requests per second: 15.29 [#/sec] (mean)
Time per request: 261.559 [ms] (mean)
Time per request: 65.390 [ms] (mean, across all concurrent requests)
Transfer rate: 8.62 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 24 32 7.4 30 81
Processing: 212 229 25.5 226 440
Waiting: 212 228 25.5 225 440
Total: 240 261 26.4 256 468
Percentage of the requests served within a certain time (ms)
50% 256
66% 260
75% 263
80% 265
90% 274
95% 283
98% 325
99% 463
100% 468 (longest request)
conclusion
una porqueria que dreamhost ponga ese limite a fastcgi, es explicable que web.py demore, ya que tiene que levantar el interprete e importar todo el framework cada vez que lo llamo solo para mostrar un hola mundo. Lo que me sorprende es que python/cgi pelado sea mas rapido que php, siendo que python tiene que levantar el interprete cada vez.
Aclaro que este microbenchmark comprueba realmente cuanto tarda en servir una peticion y no compara la velocidad de los lenguajes en si, pero eso es lo que me interesa, ya que python le pasa el trapo a php en performance :P http://shootout.alioth.debian.org/u32q/benchmark.php?test=all&lang=python&lang2=php
en resumen, no se si hacerlo en python en este host, ya que sacrificar el beneficio de un framework por una limitacion del hosting es un perno :S