<?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: Compression of dynamic content</title>
    <link>http://blog.lighttpd.net/articles/2006/12/28/compression-of-dynamic-content</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Compression of dynamic content</title>
      <description>&lt;p&gt;It looks like a few changes won&amp;#8217;t make it into trunk/ before I leave for vacation. But you should know what is in the pipeline and what you want to wait for:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;span class="caps"&gt;HTTP&lt;/span&gt; Response filtering is implemented&lt;/li&gt;
		&lt;li&gt;&lt;span class="caps"&gt;HTTP&lt;/span&gt;/1.1 chunking becomes a module&lt;/li&gt;
		&lt;li&gt;compression of dynamic content&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;This will add compression not only for mod_proxy_core and its backends (FastCGI, &lt;span class="caps"&gt;SCGI&lt;/span&gt;, HTTP, &lt;span class="caps"&gt;AJP13&lt;/span&gt;)  but also to internally generated content like the directory listings.&lt;/p&gt;


	&lt;p&gt;With these changes we will become more and more stream based. Or like &lt;span class="caps"&gt;JDD&lt;/span&gt; called it: &lt;a href="http://blog.duncandavidson.com/2006/06/the_web_is_a_pi.html"&gt;The Web is a Pipe&lt;/a&gt;&lt;/p&gt;
</description>
      <pubDate>Thu, 28 Dec 2006 23:49:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:24afa6d0-efe5-4dab-8045-673670e88175</guid>
      <author>jan</author>
      <link>http://blog.lighttpd.net/articles/2006/12/28/compression-of-dynamic-content</link>
      <category>lighttpd</category>
      <category>compression</category>
      <trackback:ping>http://blog.lighttpd.net/articles/trackback/2620</trackback:ping>
    </item>
    <item>
      <title>"Compression of dynamic content" by QHY</title>
      <description>I have found several bugs of mod_deflate and patch at &lt;a href="http://blog.quehy.com/doc/lighttpd-1.5.trunk.mod_deflate.patch" rel="nofollow"&gt;http://blog.quehy.com/doc/lighttpd-1.5.trunk.mod_deflate.patch&lt;/a&gt;

, detail at &lt;a href="http://blog.quehy.com/archives/184.html" rel="nofollow"&gt;http://blog.quehy.com/archives/184.html&lt;/a&gt;</description>
      <pubDate>Fri, 19 Jan 2007 08:08:05 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:88717a42-7479-471f-9e1d-21eb41aaac6c</guid>
      <link>http://blog.lighttpd.net/articles/2006/12/28/compression-of-dynamic-content#comment-3227</link>
    </item>
    <item>
      <title>"Compression of dynamic content" by refactored.net</title>
      <description>Also, might be useful if there is some indication that you've submitted a comment. Maybe disable submit until the comment is show/timeout?</description>
      <pubDate>Wed, 10 Jan 2007 13:40:28 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:bc479d9d-fb05-4c5d-9c60-950659b5c7c3</guid>
      <link>http://blog.lighttpd.net/articles/2006/12/28/compression-of-dynamic-content#comment-3124</link>
    </item>
    <item>
      <title>"Compression of dynamic content" by refactored.net</title>
      <description>Could we also set a header from (f)cgi scripts (maybe X-LIGHTTPD-compress-response: on|off or something) to turn it on|off on a response basis? I think this would be useful.</description>
      <pubDate>Wed, 10 Jan 2007 13:39:33 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:c80991c3-d998-43ee-af80-242975d5ba8a</guid>
      <link>http://blog.lighttpd.net/articles/2006/12/28/compression-of-dynamic-content#comment-3123</link>
    </item>
    <item>
      <title>"Compression of dynamic content" by servertweak.com</title>
      <description>I've tried the patch of mod_deflate, there are a few problems such as seeing half of the page load now and then. 

I can see mod_deflate beneficial when there are a X load balancing servers and 1 frontend server proxying all of the requests. the load balancers may be overloaded so by not doing the compression on the load balancers it will lower it's load and increase load in the frontend which will do the compression there.

I've seen minimal performance increases or drops in serverload if PHP and mod_deflate run on the same server. Afterall, all of the compression is done via the library.</description>
      <pubDate>Tue, 09 Jan 2007 22:33:26 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:774de945-b7df-48c8-a603-08fbbe6ac861</guid>
      <link>http://blog.lighttpd.net/articles/2006/12/28/compression-of-dynamic-content#comment-3039</link>
    </item>
    <item>
      <title>"Compression of dynamic content" by FreeDude</title>
      <description>OK, so with work-block-size set to something small (512 bytes, I assume the manual is incorrect to talk about _kilo_ bytes?) the latency increase should be minimal. But when you have a multi processor server, it just seems to me that the other CPU's are still a better place to do the compression. That is assuming that the OS is smart enough to distribute the load... Does anybody have any real world numbers on this?</description>
      <pubDate>Mon, 08 Jan 2007 22:27:08 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:43b28e22-44dc-4a12-b882-b7576eb0f90a</guid>
      <link>http://blog.lighttpd.net/articles/2006/12/28/compression-of-dynamic-content#comment-2847</link>
    </item>
    <item>
      <title>"Compression of dynamic content" by Jakabosky</title>
      <description>mod_deflate doesn't compress the whole response all at once.  There is an option "deflate.work-block-size" to tune how much of the response gets compressed at one time.  That allows I/O and compression work to be mixed.&lt;br&gt;
&lt;br&gt;
For some websites the backend has to do a lot of work.  So moving some of the cpu work to the frontend will help balance the work load.&lt;br&gt;
&lt;br&gt;
Also mod_deflate can be turned on/off for any mime type, url or user agent.</description>
      <pubDate>Mon, 08 Jan 2007 20:56:58 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:19c7af55-c008-4cd4-a904-e7935a6e22a5</guid>
      <link>http://blog.lighttpd.net/articles/2006/12/28/compression-of-dynamic-content#comment-2846</link>
    </item>
    <item>
      <title>"Compression of dynamic content" by FreeDude</title>
      <description>Yeah, but while the data is compressed lighttpd will block. When the compression is done in the backend, lighttpd can still accept and process other connections.</description>
      <pubDate>Mon, 08 Jan 2007 17:38:27 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:ee91e7b8-0723-4698-9caf-804a4f467d11</guid>
      <link>http://blog.lighttpd.net/articles/2006/12/28/compression-of-dynamic-content#comment-2845</link>
    </item>
    <item>
      <title>"Compression of dynamic content" by QHY</title>
      <description>php's gzip compress performance is far lower than mod_deflate. mod_deflate eats 10% CPU at most from my usage experiences</description>
      <pubDate>Mon, 08 Jan 2007 03:59:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:eee7bba7-191b-437a-b3f7-a2652e7651fe</guid>
      <link>http://blog.lighttpd.net/articles/2006/12/28/compression-of-dynamic-content#comment-2844</link>
    </item>
    <item>
      <title>"Compression of dynamic content" by FreeDude</title>
      <description>Won't dynamic compression (mod_deflate) hurt lighttpd performance (i.e. block)?  I thought that dynamic compression should be handled by the backend (i.e. PHP) and not by the single threaded lighttpd server.</description>
      <pubDate>Sat, 06 Jan 2007 10:24:18 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:2a342518-f053-4993-ba3b-0a07b572c349</guid>
      <link>http://blog.lighttpd.net/articles/2006/12/28/compression-of-dynamic-content#comment-2818</link>
    </item>
    <item>
      <title>"Compression of dynamic content" by Jakabosky</title>
      <description>I have committed to trunk:
&lt;ul&gt;
&lt;li&gt;new filter chain API&lt;/li&gt;
&lt;li&gt;mod_chunked (HTTP/1.1 chunked encoding)&lt;/li&gt;
&lt;li&gt;mod_deflate (dynamic compression)&lt;/li&gt;
&lt;/ul&gt;

New response filtering modules can be made easily now.&lt;br&gt;
&lt;br&gt;
mod_ssi (server side includes) should be converted to a filter, that way any dynamic content can include static headers/footers.&lt;br&gt;
</description>
      <pubDate>Sat, 06 Jan 2007 07:22:33 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:68e8e5a2-cc6d-4945-aebb-b7045ef51e50</guid>
      <link>http://blog.lighttpd.net/articles/2006/12/28/compression-of-dynamic-content#comment-2810</link>
    </item>
    <item>
      <title>"Compression of dynamic content" by Mike</title>
      <description>Hi all,

This reply is related to a previous thread called "Faster FastCGI", I was unable to submit it there.&lt;br&gt;&lt;br&gt;Im sorry, there seems to be a problem leaving comments on firefox =(&lt;br&gt;
&lt;br&gt;
Just to say, someone mentioned caching of dynamic pages. My opinion is its prolly not best to do any sort of caching on dynamic text.. Its normally better practise to make faster code than cache sections of it.&lt;br&gt;
&lt;br&gt;
However, What i do thing would be a good idea is to determine what is dynamic PHP and static PHP, for example I use PHP files for all my pages, not just dynamic ones. So we could cache anything that does not use a function except echo and print. &lt;br&gt;Simple =)&lt;br&gt;
&lt;br&gt;
e.g.&lt;br&gt;
&lt;br&gt;
(a PHP file with no code sections)&lt;br&gt;
&amp;lt;?php $c = 0; $c++; echo $c; ?&amp;gt;&lt;br&gt;
&amp;lt;?php echo "testing..."; ?&amp;gt; can all be cached.&lt;br&gt;
&amp;lt;?php echo rand(); ?&amp;gt; can't.&lt;br&gt;
&lt;br&gt;
This gets alittle more complex when you start to think about includes and if statements involving external arguments. but im sure there are solutions for them too.&lt;br&gt;
&lt;br&gt;
That is the only case of caching I can think of. I dont know how caching is handled, but i presume that if the cachefile exists it will send it, if the cache file doesnt its tested and cached if pos, so this could easily be implimented.&lt;br&gt;
&lt;br&gt;
Anyway, This original thread is about using temp files to send large amounts of data to the core from swarm-fcgi. I believe that the current IPC is via Unix Sockets, which are handled by the kernel and should be the fastest method available. I have a  little understanding on the current method used, but what i think would be the fastest would be to &lt;br&gt;
&lt;br&gt;
Create a triangle pipe/IPC system, something like&lt;br&gt;
&lt;br&gt;
1. Fork() "forwarder"&lt;br&gt;
2. pair TCP/Unix socket with a Pipe[out]&lt;br&gt;
3. Pipe[in] send request to fcgi&lt;br&gt;
4. fcgi send output to "forwarder" on Pipe[out]&lt;br&gt;
5. The "forwarder" thread passes on the information recieved to the TCP/Unix socket.&lt;br&gt;
&lt;br&gt;
I had a quick read on mod_fastcgi.c but its a pretty big file. From what i could understand is that this module forks off anyway, and runs the CGI scripts. If so, you could just forward two fd handles to the fork(), 1 for the TCP output, and 1 for the PIPE errors/cmds. This would mean that the "core" would get the page request, forward the fd handle to the cgi module, the cgi module would do its stuff in its own thread, once complete it would send the result down the TCP connection and either close it, itself or hand it back over to the core to close.&lt;br&gt;
&lt;br&gt;
Mike&lt;br&gt;
&lt;br&gt;
P.s, Give vfork() a go instead of fork(). This should save some memory on each cgi thread as it shares memory and thread's until execve(). It will require removing the code that clears the fd handles etc.&lt;br&gt;
&lt;br&gt;
&lt;a href="http://www.hmug.org/man/2/vfork.php" rel="nofollow"&gt;http://www.hmug.org/man/2/vfork.php&lt;/a&gt;</description>
      <pubDate>Fri, 29 Dec 2006 03:05:22 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:762e8665-b93c-43fa-8904-f78bef1a062b</guid>
      <link>http://blog.lighttpd.net/articles/2006/12/28/compression-of-dynamic-content#comment-2658</link>
    </item>
  </channel>
</rss>
