<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>lighty's life: Faster FastCGI</title>
    <link>http://blog.lighttpd.net/articles/2006/11/29/faster-fastcgi</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Faster FastCGI</title>
      <description>&lt;p&gt;While I was throwing away from bogus data-copy operations from the mod-proxy-core code I stumbled over a simple question:&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;Why do we copy the &lt;span class="caps"&gt;HTTP&lt;/span&gt; response data from the backends at all ?&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;We are just forwarding them in most cases without touching them.&lt;/p&gt;
&lt;p&gt;How about:&lt;/p&gt;


&lt;pre&gt;
HTTP/1.1 200 OK
Content-Type: text/html
X-LIGHTTPD-send-tempfile: /dev/shm/fcgi-output/j37f467d

&lt;/pre&gt;

	&lt;p&gt;... and lighty removing the file when it has sent it.&lt;/p&gt;


	&lt;p&gt;&lt;i&gt;/dev/shm&lt;/i&gt; is memory and the application is writing to it and only passes a reference to the webserver where it can take the content from.&lt;/p&gt;


	&lt;p&gt;Especially for large content which is generated on the fly this might help alot.&lt;/p&gt;


&lt;h3&gt;Crazy or Cool&lt;/h3&gt;

	&lt;p&gt;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.&lt;/p&gt;</description>
      <pubDate>Wed, 29 Nov 2006 13:02:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:a057792d-9195-4086-a759-eadd766d9cf8</guid>
      <author>jan</author>
      <link>http://blog.lighttpd.net/articles/2006/11/29/faster-fastcgi</link>
      <category>lighttpd</category>
      <trackback:ping>http://blog.lighttpd.net/articles/trackback/2512</trackback:ping>
    </item>
    <item>
      <title>"Faster FastCGI" by Matt</title>
      <description>Would it be neat to see a way to serve content directly from a memcached, using a header like "X-LIGHTTPD-send-file: memcache:10.0.0.1:11111:thekey" ? Haven't really figured out where it could/would make a big difference, but maybe? Difficult to implement? Shouldn't be, right?
</description>
      <pubDate>Fri, 22 Dec 2006 13:10:37 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:fd7cbaae-8d13-4110-ae8a-696918c90825</guid>
      <link>http://blog.lighttpd.net/articles/2006/11/29/faster-fastcgi#comment-2596</link>
    </item>
    <item>
      <title>"Faster FastCGI" by Matt</title>
      <description>Would it be neat to see a way to serve content directly from a memcached, using a header like "X-LIGHTTPD-send-file: memcache:10.0.0.1:11111:thekey" ? Haven't really figured out where it could/would make a big difference, but maybe? Difficult to implement? Shouldn't be, right?
</description>
      <pubDate>Fri, 22 Dec 2006 13:09:20 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:93646b8f-d7b0-4ce2-bc60-fed13d4c5e37</guid>
      <link>http://blog.lighttpd.net/articles/2006/11/29/faster-fastcgi#comment-2595</link>
    </item>
    <item>
      <title>"Faster FastCGI" by Jan Kneschke</title>
      <description>Valentin, back in the mod_cml days it was handled like this: If the cached files are you of date, ask the backend to generated the content and update the files and only let mod-magnet handle the cache-hit case. Usually you can move the logic about freshness of the cache into mod-magnet and use timestamps, hashes in memcache, ... as source for deciding about the request and cache-hit/-miss.</description>
      <pubDate>Fri, 22 Dec 2006 07:00:37 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:ec03bcb6-bbab-4cdb-9513-ae93604cebe7</guid>
      <link>http://blog.lighttpd.net/articles/2006/11/29/faster-fastcgi#comment-2591</link>
    </item>
    <item>
      <title>"Faster FastCGI" by Jan Kneschke</title>
      <description>Romuald, the connection the FastCGI is persistent in 1.5.0. See &lt;a href="http://blog.lighttpd.net/articles/2006/10/08/reducing-requests-setup-costs" rel="nofollow"&gt;http://blog.lighttpd.net/articles/2006/10/08/reducing-requests-setup-costs&lt;/a&gt; for some numbers.</description>
      <pubDate>Fri, 22 Dec 2006 06:57:54 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:f3362a88-4e78-4a28-8a99-f35bece9547b</guid>
      <link>http://blog.lighttpd.net/articles/2006/11/29/faster-fastcgi#comment-2590</link>
    </item>
    <item>
      <title>"Faster FastCGI" by Valentin</title>
      <description>I mean rather X-LIGHTTPD-send-file Header for multiple puzzle pieces. FastCGI is synchron, but Lighttp - asynchron. In addition are the pieces often reusable.</description>
      <pubDate>Thu, 21 Dec 2006 17:27:44 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:85fd6f84-7604-419b-a9e5-a5d28044ff2b</guid>
      <link>http://blog.lighttpd.net/articles/2006/11/29/faster-fastcgi#comment-2588</link>
    </item>
    <item>
      <title>"Faster FastCGI" by Romuald</title>
      <description>Wouldn't be even faster if persistent FastCGI and multiplexing were implemented ? Cause with current implementation, you would open/close a fast CGI connection for as few as a X-LIGHTTPD-send-tempfile header...</description>
      <pubDate>Thu, 21 Dec 2006 17:15:48 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:721a8567-f316-4ae3-b852-a18b3c96c23d</guid>
      <link>http://blog.lighttpd.net/articles/2006/11/29/faster-fastcgi#comment-2587</link>
    </item>
    <item>
      <title>"Faster FastCGI" by Valentin</title>
      <description>I want to return file-set AFTER the cache update, but its impossible  with mod_magnet</description>
      <pubDate>Thu, 21 Dec 2006 16:23:31 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:a2000a0c-3545-4eec-970a-11856be01b93</guid>
      <link>http://blog.lighttpd.net/articles/2006/11/29/faster-fastcgi#comment-2586</link>
    </item>
    <item>
      <title>"Faster FastCGI" by Jan Kneschke</title>
      <description>valentin, use mod_magnet in do it there directly. </description>
      <pubDate>Fri, 15 Dec 2006 22:25:54 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:3690a9d3-465e-4b13-b307-d5d5b04ec96d</guid>
      <link>http://blog.lighttpd.net/articles/2006/11/29/faster-fastcgi#comment-2566</link>
    </item>
    <item>
      <title>"Faster FastCGI" by Valentin</title>
      <description>Ich wünsche mir, man kann mehrere Dateien zurücksenden:


HTTP/1.1 200 OK
Content-Type: text/html
X-LIGHTTPD-send-tempfile: /dev/shm/fcgi-output/header,body,footer</description>
      <pubDate>Fri, 15 Dec 2006 16:08:35 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:50959d73-a211-4759-b362-62fd869883a7</guid>
      <link>http://blog.lighttpd.net/articles/2006/11/29/faster-fastcgi#comment-2565</link>
    </item>
    <item>
      <title>"Faster FastCGI" by Jakabosky</title>
      <description>I did some more testing a noticed that lighttpd 1.4.0 was using&lt;br&gt;
more cpu then lighttpd 1.5.0 during the test.&lt;br&gt;
&lt;br&gt;
I am going to rerun the apache bench from another computer,&lt;br&gt;
so lighttpd and php will have the whole cpu.</description>
      <pubDate>Thu, 07 Dec 2006 04:37:15 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:282946ad-dd7f-49bd-a3a9-1504e527e21a</guid>
      <link>http://blog.lighttpd.net/articles/2006/11/29/faster-fastcgi#comment-2550</link>
    </item>
    <item>
      <title>"Faster FastCGI" by Jakabosky</title>
      <description>This feature will only be faster when the response content is atleast&lt;br&gt;
16Kbytes.  Each 16Kbytes of content will need atleast one &lt;br&gt;
read() by lighttpd from the fastcgi connection.  When the response&lt;br&gt;
content is returned in the tempfile, lighttpd only needs to do&lt;br&gt;
one read() for the response headers.&lt;br&gt;
&lt;br&gt;
Here is a test with a php script that generate 512k of content&lt;br&gt;
&lt;br&gt;
lighttpd 1.4.11&lt;br&gt;
ab -n4000 &lt;a href="http://localhost:1080/send-tempfile.php?use_temp=0" rel="nofollow"&gt;http://localhost:1080/send-tempfile.php?use_temp=0&lt;/a&gt;&lt;br&gt;
lighttpd 1.4.11&lt;br&gt;
Concurrency Level:      1&lt;br&gt;
Time taken for tests:   18.691657 seconds&lt;br&gt;
Complete requests:      4000&lt;br&gt;
HTML transferred:       2097152000 bytes&lt;br&gt;
Requests per second:    214.00 [#/sec] (mean)&lt;br&gt;
Time per request:       4.673 [ms] (mean)&lt;br&gt;
Time per request:       4.673 [ms] (mean, across all concurrent requests)&lt;br&gt;
Transfer rate:          109593.93 [Kbytes/sec] received&lt;br&gt;
&lt;br&gt;
lighttpd 1.5.0(patched)&lt;br&gt;
ab -n4000 &lt;a href="http://localhost:1080/send-tempfile.php?use_temp=1" rel="nofollow"&gt;http://localhost:1080/send-tempfile.php?use_temp=1&lt;/a&gt;&lt;br&gt;
Concurrency Level:      1&lt;br&gt;
Time taken for tests:   17.239221 seconds&lt;br&gt;
Complete requests:      4000&lt;br&gt;
HTML transferred:       2097152000 bytes&lt;br&gt;
Requests per second:    232.03 [#/sec] (mean)&lt;br&gt;
Time per request:       4.310 [ms] (mean)&lt;br&gt;
Time per request:       4.310 [ms] (mean, across all concurrent requests)&lt;br&gt;
Transfer rate:          118831.00 [Kbytes/sec] received&lt;br&gt;
&lt;br&gt;
1.5.0 with send-tempfile is only 18 requests per second faster&lt;br&gt;
So the difference is still not that greate.&lt;br&gt;
See 
&lt;a href="http://trac.lighttpd.net/trac/ticket/922" rel="nofollow"&gt;ticket #922&lt;/a&gt;
for patch and send-tempfile.php&lt;br&gt;
&lt;br&gt;
I would only use the send-tempfile feature for large responses.&lt;br&gt;
If you have a server with alot of ram and it needs to send large&lt;br&gt;
responses to many clients then this feature might help.&lt;br&gt;
just make sure you allocate enought space to /dev/shm/</description>
      <pubDate>Thu, 07 Dec 2006 03:33:34 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:8b253a1e-e279-4c75-8d84-37395db9b293</guid>
      <link>http://blog.lighttpd.net/articles/2006/11/29/faster-fastcgi#comment-2549</link>
    </item>
    <item>
      <title>"Faster FastCGI" by boom@bamex.ru</title>
      <description>I tested lighttpd 1.4.11 vs lighttpd 1.5.0-svn (faster fast_cgi on) with php 5.2.0&lt;br&gt;
1.4.11 slower that 1.5.0 &lt;br&gt;&lt;br&gt;
# ab2 -n100 &lt;a href="http://test.com" rel="nofollow"&gt;http://test.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;br&gt;

1.4.11&lt;br&gt;
Requests per second:    4.34 [#/sec] (mean)&lt;br&gt;
Time per request:       230.197 [ms] (mean)&lt;br&gt;
Time per request:       230.197 [ms] (mean, across all concurrent requests)&lt;br&gt;
Transfer rate:          87.45 [Kbytes/sec] received&lt;br&gt;
&lt;br&gt;
Connection Times (ms)&lt;br&gt;
              min  mean[+/-sd] median   max&lt;br&gt;
Connect:        0    0   0.1      0       1&lt;br&gt;
Processing:   209  229  74.9    219     960&lt;br&gt;
Waiting:      200  218  74.1    204     939&lt;br&gt;
Total:        209  229  75.0    219     961&lt;br&gt;
&lt;br&gt;


1.5.0&lt;br&gt;
Requests per second:    4.55 [#/sec] (mean)&lt;br&gt;
Time per request:       219.888 [ms] (mean)&lt;br&gt;
Time per request:       219.888 [ms] (mean, across all concurrent requests)&lt;br&gt;
Transfer rate:          91.55 [Kbytes/sec] received&lt;br&gt;
&lt;br&gt;
Connection Times (ms)&lt;br&gt;
              min  mean[+/-sd] median   max&lt;br&gt;
Connect:        0    0   0.0      0       0&lt;br&gt;
Processing:   206  219  16.5    212     297&lt;br&gt;
Waiting:      194  207  15.2    201     278&lt;br&gt;
Total:        206  219  16.5    212     297&lt;br&gt;

&lt;br&gt;&lt;br&gt;
but in some cases 1.4.11 faster that 1.5.0 on large php scripts
</description>
      <pubDate>Sun, 03 Dec 2006 15:57:17 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:ed01e1b2-5a8e-4e6f-8600-0ab27c33741c</guid>
      <link>http://blog.lighttpd.net/articles/2006/11/29/faster-fastcgi#comment-2537</link>
    </item>
    <item>
      <title>"Faster FastCGI" by Marty</title>
      <description>Isn't it better (faster?) to let PHP do the compression anyway?</description>
      <pubDate>Sat, 02 Dec 2006 14:05:17 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:337b83be-43bd-41c7-8b24-9489bb70bb91</guid>
      <link>http://blog.lighttpd.net/articles/2006/11/29/faster-fastcgi#comment-2536</link>
    </item>
    <item>
      <title>"Faster FastCGI" by Jakabosky</title>
      <description>I have implemented this feature for lighttpd-1.5.0&lt;br&gt;
Find the patch attached to 
&lt;a href="http://trac.lighttpd.net/trac/ticket/922" rel="nofollow"&gt;ticket #922&lt;/a&gt;&lt;br&gt;

There is also an example php script.&lt;br&gt;
&lt;br&gt;
This feature can be made to work with mod_deflate.&lt;br&gt;
Currently mod_deflate has not been ported to 1.5.0.</description>
      <pubDate>Sat, 02 Dec 2006 07:24:42 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:1bf4aaac-1b81-41f3-9a5f-062639d795af</guid>
      <link>http://blog.lighttpd.net/articles/2006/11/29/faster-fastcgi#comment-2535</link>
    </item>
    <item>
      <title>"Faster FastCGI" by Russ</title>
      <description>I just had a thought - this would presumably not work with the compression mod, as the output would go straight to the socket, where usually it would go fast-cgi - lighty - compress - user?

You could get around this by having PHP (etc) doing the compression.

Or have I missed something.</description>
      <pubDate>Fri, 01 Dec 2006 13:03:50 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:17fd7a41-921f-4295-9fca-a8a59a79d209</guid>
      <link>http://blog.lighttpd.net/articles/2006/11/29/faster-fastcgi#comment-2527</link>
    </item>
    <item>
      <title>"Faster FastCGI" by Russ</title>
      <description>Very neat idea! Are you going to implement it?</description>
      <pubDate>Thu, 30 Nov 2006 16:59:29 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:95521390-0629-410b-8785-960f99739d79</guid>
      <link>http://blog.lighttpd.net/articles/2006/11/29/faster-fastcgi#comment-2526</link>
    </item>
    <item>
      <title>"Faster FastCGI" by Russ</title>
      <description>Very neat idea! Are you going to implement it?</description>
      <pubDate>Thu, 30 Nov 2006 16:58:45 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:b52c59d6-9487-401c-9ab3-786bbdd34d91</guid>
      <link>http://blog.lighttpd.net/articles/2006/11/29/faster-fastcgi#comment-2525</link>
    </item>
    <item>
      <title>"Faster FastCGI" by Ben Harper</title>
      <description>Rr- You would still avoid a memcpy on the backend machines, as spawnfcgi pumps data back to the server.</description>
      <pubDate>Thu, 30 Nov 2006 15:15:57 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:40ff8686-8227-4f44-9445-6efbd47673dc</guid>
      <link>http://blog.lighttpd.net/articles/2006/11/29/faster-fastcgi#comment-2524</link>
    </item>
    <item>
      <title>"Faster FastCGI" by Rr</title>
      <description>And how would it work in more than one fastcgi backend environment (remote boxes)?</description>
      <pubDate>Thu, 30 Nov 2006 12:17:29 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:6b7f97fc-8b97-4105-9517-9b5641d1f123</guid>
      <link>http://blog.lighttpd.net/articles/2006/11/29/faster-fastcgi#comment-2523</link>
    </item>
    <item>
      <title>"Faster FastCGI" by Ben Harper</title>
      <description>I like it. Simply avoids an extra memcpy?</description>
      <pubDate>Thu, 30 Nov 2006 06:30:08 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:01e96e0a-c7fe-4838-9f0d-cc6f13f6c84b</guid>
      <link>http://blog.lighttpd.net/articles/2006/11/29/faster-fastcgi#comment-2522</link>
    </item>
    <item>
      <title>"Faster FastCGI" by Jakabosky</title>
      <description>The FastCGI app may not be able to cache the full content.&lt;br&gt;
Parts of the content may still need to be generated dynamically.&lt;br&gt;
I have worked on a website that pulls cached data from&lt;br&gt;
different data sources.  Caching the full page wouldn't work&lt;br&gt;
since each data source has different refresh intervals and &lt;br&gt;
might be used on multiple pages.&lt;br&gt;
</description>
      <pubDate>Thu, 30 Nov 2006 02:15:08 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:951eb0a0-8dc3-490a-a6d0-d9843ca2bc67</guid>
      <link>http://blog.lighttpd.net/articles/2006/11/29/faster-fastcgi#comment-2521</link>
    </item>
    <item>
      <title>"Faster FastCGI" by Scott Yang</title>
      <description>And what's the difference with the current X-LIGHTTPD-sendfile implementation beside the sent filename reference will be removed at the end of the request?

I thought for sending large content, it would be wiser to let FastCGI apps to intelligently cache the generated result, instead of having delete/re-generate/delete/re-generate cycle even if the intermediate content is stored in fast shared memory?</description>
      <pubDate>Thu, 30 Nov 2006 00:29:59 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:4022773c-0bd2-4fd7-9d73-a6e1f87328dc</guid>
      <link>http://blog.lighttpd.net/articles/2006/11/29/faster-fastcgi#comment-2520</link>
    </item>
    <item>
      <title>"Faster FastCGI" by Jakabosky</title>
      <description>I like this idea.  It can be used with &lt;br&gt;mod_cgi/mod_fastcgi/mod_proxy/mod_proxy_core&lt;br&gt;
&lt;br&gt;
Elliptical: who said it has to be HTTP/1.1 compatible, as long as the &lt;br&gt;
header is unique and lighttpd removes it from the response to &lt;br&gt;
the client it will not cause any compatiblity problems.</description>
      <pubDate>Wed, 29 Nov 2006 23:21:55 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:3aa92473-112d-40bb-8d10-c54074e16026</guid>
      <link>http://blog.lighttpd.net/articles/2006/11/29/faster-fastcgi#comment-2519</link>
    </item>
    <item>
      <title>"Faster FastCGI" by Elliptical Workouts</title>
      <description>I'm afraid it's a crazy idea to make it. It's not HTTP/1.1 compartible.</description>
      <pubDate>Wed, 29 Nov 2006 20:52:01 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:ca34e188-9a44-4a70-b61a-91bf272c06ca</guid>
      <link>http://blog.lighttpd.net/articles/2006/11/29/faster-fastcgi#comment-2518</link>
    </item>
    <item>
      <title>"Faster FastCGI" by Fernando Silva</title>
      <description>It sounds brilliantly crazy!</description>
      <pubDate>Wed, 29 Nov 2006 20:40:38 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:4cd856e8-eba6-48fe-824f-f126c921e141</guid>
      <link>http://blog.lighttpd.net/articles/2006/11/29/faster-fastcgi#comment-2517</link>
    </item>
  </channel>
</rss>
