I was reading a little bit about Apache optimization tonight and an article suggested offloading all image requests to a lighttpd server via mod_proxy. On the surface it made a lot of sense because a sysadmin can throw mod_proxy and lighttpd up without needing to notify web developers or change site content. However, from my tests it looks like Apache + mod_proxy + lighttpd is slower than just Apache and much slower than a standalone lighttpd server for static content. For my tests I used the http_load application.
Case 1 – lighttpd v1.4.15 serving a 9.05k image file
# http_load -parallel 10 -seconds 10 url
183259 fetches, 10 max parallel, 1.69881e+09 bytes, in 10 seconds
9270 mean bytes/connection
18325.9 fetches/sec, 1.69881e+08 bytes/sec
msecs/connect: 0.0889203 mean, 3.338 max, 0.023 min
msecs/first-response: 0.340411 mean, 9.85 max, 0.11 min
HTTP response codes:
code 200 -- 183259
That’s 183,259 requests handled in 10 seconds.
Case 2 – Apache v2.2.3 serving a 9.05k image file
# http_load -parallel 10 -seconds 10 url
88581 fetches, 10 max parallel, 8.21146e+08 bytes, in 10.0002 seconds
9270 mean bytes/connection
8857.92 fetches/sec, 8.21129e+07 bytes/sec
msecs/connect: 0.115481 mean, 5.775 max, 0.021 min
msecs/first-response: 0.799573 mean, 69.448 max, 0.102 min
HTTP response codes:
code 200 -- 88581
88,581 requests in 10 seconds. Clearly lighttpd is faster. What happens if we combine them as the article suggests?
Case 3 – Apache v2.2.3 + mod_proxy + lighttpd v1.4.15
# http_load -parallel 10 -seconds 10 url
39435 fetches, 10 max parallel, 3.65562e+08 bytes, in 10.0001 seconds
9270 mean bytes/connection
3943.47 fetches/sec, 3.65559e+07 bytes/sec
msecs/connect: 0.180241 mean, 7.756 max, 0.022 min
msecs/first-response: 2.05521 mean, 150.937 max, 0.301 min
HTTP response codes:
code 200 -- 39435
38,435 requests served in 10 seconds. This is worse than a standalone Apache web server.
My conclusion: Use http://images.domain.com/ for your static content and let lighttpd serve it as fast as possible.
Geek - 4 Comments »