Faster FastCGI 26
While I was throwing away from bogus data-copy operations from the mod-proxy-core code I stumbled over a simple question:
Why do we copy the HTTP response data from the backends at all ?
We are just forwarding them in most cases without touching them.
How about:
HTTP/1.1 200 OK Content-Type: text/html X-LIGHTTPD-send-tempfile: /dev/shm/fcgi-output/j37f467d
... and lighty removing the file when it has sent it.
/dev/shm is memory and the application is writing to it and only passes a reference to the webserver where it can take the content from.
Especially for large content which is generated on the fly this might help alot.
Crazy or Cool
Now it takes someone to implement and benchmark it. Adding it as easy: just add the header filter to mod_fastcgi and set is_temp on the file-chunk.
Trackbacks
Use the following link to trackback from your own site:
http://blog.lighttpd.net/articles/trackback/2512
-
In Faster FastCGI I talked about using temp-files in /dev/shm to reduce the overhead of large FastCGI requests. Robert implemented it right away and it is available in the latest pre-release Woken up far too early and having the first coffee I sha...
mod_cgi/mod_fastcgi/mod_proxy/mod_proxy_core
Elliptical: who said it has to be HTTP/1.1 compatible, as long as the
header is unique and lighttpd removes it from the response to
the client it will not cause any compatiblity problems.
Parts of the content may still need to be generated dynamically.
I have worked on a website that pulls cached data from
different data sources. Caching the full page wouldn't work
since each data source has different refresh intervals and
might be used on multiple pages.
Find the patch attached to ticket #922
There is also an example php script.
This feature can be made to work with mod_deflate.
Currently mod_deflate has not been ported to 1.5.0.
1.4.11 slower that 1.5.0
# ab2 -n100 http://test.com
1.4.11
Requests per second: 4.34 [#/sec] (mean)
Time per request: 230.197 [ms] (mean)
Time per request: 230.197 [ms] (mean, across all concurrent requests)
Transfer rate: 87.45 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 1
Processing: 209 229 74.9 219 960
Waiting: 200 218 74.1 204 939
Total: 209 229 75.0 219 961
1.5.0
Requests per second: 4.55 [#/sec] (mean)
Time per request: 219.888 [ms] (mean)
Time per request: 219.888 [ms] (mean, across all concurrent requests)
Transfer rate: 91.55 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 206 219 16.5 212 297
Waiting: 194 207 15.2 201 278
Total: 206 219 16.5 212 297
but in some cases 1.4.11 faster that 1.5.0 on large php scripts
16Kbytes. Each 16Kbytes of content will need atleast one
read() by lighttpd from the fastcgi connection. When the response
content is returned in the tempfile, lighttpd only needs to do
one read() for the response headers.
Here is a test with a php script that generate 512k of content
lighttpd 1.4.11
ab -n4000 http://localhost:1080/send-tempfile.php?use_temp=0
lighttpd 1.4.11
Concurrency Level: 1
Time taken for tests: 18.691657 seconds
Complete requests: 4000
HTML transferred: 2097152000 bytes
Requests per second: 214.00 [#/sec] (mean)
Time per request: 4.673 [ms] (mean)
Time per request: 4.673 [ms] (mean, across all concurrent requests)
Transfer rate: 109593.93 [Kbytes/sec] received
lighttpd 1.5.0(patched)
ab -n4000 http://localhost:1080/send-tempfile.php?use_temp=1
Concurrency Level: 1
Time taken for tests: 17.239221 seconds
Complete requests: 4000
HTML transferred: 2097152000 bytes
Requests per second: 232.03 [#/sec] (mean)
Time per request: 4.310 [ms] (mean)
Time per request: 4.310 [ms] (mean, across all concurrent requests)
Transfer rate: 118831.00 [Kbytes/sec] received
1.5.0 with send-tempfile is only 18 requests per second faster
So the difference is still not that greate.
See ticket #922 for patch and send-tempfile.php
I would only use the send-tempfile feature for large responses.
If you have a server with alot of ram and it needs to send large
responses to many clients then this feature might help.
just make sure you allocate enought space to /dev/shm/
more cpu then lighttpd 1.5.0 during the test.
I am going to rerun the apache bench from another computer,
so lighttpd and php will have the whole cpu.