<?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: Tag mod_proxy_core</title>
    <link>http://blog.lighttpd.net/articles/tag/mod_proxy_core</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>PRE-RELEASE: lighttpd-1.5.0-r1454.tar.gz</title>
      <description>&lt;p&gt;Thanks to brave testers in #lighttpd the &lt;span class="caps"&gt;AIO&lt;/span&gt;-support is stabilizing very well and the corruptions that have been reported are fixed now.&lt;/p&gt;


	&lt;p&gt;Next to bugfixes, I implemented chunk-stealing and doubled the performance of aio for small files (100k) [16MByte/s instead of 9MByte/s].&lt;/p&gt;


	&lt;p&gt;Download: &lt;a href="http://www.lighttpd.net/download/lighttpd-1.5.0-r1454.tar.gz"&gt;http://www.lighttpd.net/download/lighttpd-1.5.0-r1454.tar.gz&lt;/a&gt;&lt;/p&gt;
</description>
      <pubDate>Wed, 15 Nov 2006 22:57:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:4d2a3dbe-dc3e-4259-a55b-a2ae12790c97</guid>
      <author>jan</author>
      <link>http://blog.lighttpd.net/articles/2006/11/15/pre-release-lighttpd-1-5-0-r1454-tar-gz</link>
      <category>lighttpd</category>
      <category>aio</category>
      <category>mod_proxy_core</category>
      <category>1.5.0</category>
      <trackback:ping>http://blog.lighttpd.net/articles/trackback/2243</trackback:ping>
    </item>
    <item>
      <title>mod_proxy_core got X-Sendfile Support</title>
      <description>&lt;p&gt;As promissed mod_proxy_core would combine the features from mod_proxy and mod_fastcgi.&lt;/p&gt;


	&lt;p&gt;mod_proxy gave the balancers, mod_fastcgi gave its fail-over handling and now support for X-Sendfile.&lt;/p&gt;
&lt;p&gt;The implementation for the feature is a bit different than it was done in mod_fastcgi.&lt;/p&gt;


	&lt;p&gt;The old implementation only replaced the content-body with the static-file and sent it out. The new implementation does it slightly different and gains a whole set of benifits.&lt;/p&gt;


	&lt;p&gt;When the X-Sendfile header is detected (and is allowed in the config) the content-body is ignored and a internal redirect is done. mod_proxy_core takes itself out of the loop and mod_staticfile takes over the request.&lt;/p&gt;


mod_staticfile can do all the magic:
	&lt;ul&gt;
	&lt;li&gt;setting Last-Modified and ETag&lt;/li&gt;
		&lt;li&gt;handling &amp;#8216;304 Not Modified&amp;#8217;&lt;/li&gt;
		&lt;li&gt;handling Range requests&lt;/li&gt;
		&lt;li&gt;compression&lt;/li&gt;
	&lt;/ul&gt;


&lt;h3&gt;Setup&lt;/h3&gt;

	&lt;p&gt;The setup is as before:&lt;/p&gt;


&lt;pre&gt;
$HTTP["url"] =~ "^/bugme(/|$)" {
    proxy-core.balancer = "round-robin" 
    proxy-core.protocol = "http" 
    proxy-core.backends = ( "127.0.0.1:2000" )
    proxy-core.allow-x-sendfile = "enable" 
}
&lt;/pre&gt;

	&lt;p&gt;On port 2000 I have a small &lt;kbd&gt;$ nc -l 2000&lt;/kbd&gt; running to simulate a super complex, high secure application. &lt;kbd&gt;$ wget --header='Accept-Encoding: gzip' http://127.0.0.1:1025/bugme/upload.html&lt;/kbd&gt; is my browser replacement:&lt;/p&gt;


&lt;pre&gt;
GET /bugme/upload.html HTTP/1.0
X-Forwarded-For: 127.0.0.1
X-Host: 127.0.0.1:1025
X-Forwarded-Proto: http
User-Agent: Wget/1.10.2 (Red Hat modified)
Accept: */*
Host: 127.0.0.1:1025
Accept-Encoding: gzip
FOO: foo

HTTP/1.0 200 OK
X-Sendfile: /path/to/upload.html
&lt;/pre&gt;

	&lt;p&gt;... and there we have the compressed &lt;kbd&gt;upload.html&lt;/kbd&gt;:&lt;/p&gt;


&lt;pre&gt;
$ ls -l upload.html
-rw-rw-r--  1 jan jan 661 Sep 26  2005 upload.html
$ ls -l /path/to/upload.html
-rw-rw-r--  1 jan jan 1193 Sep 26  2005 /path/to/upload.html
&lt;/pre&gt;

	&lt;p&gt;All you have to do in your application is setting the X-Sendfile header:&lt;/p&gt;


&lt;pre&gt;
&amp;lt;?php
  header("X-Sendfile: /path/to/upload.html");
?&amp;gt;
&lt;/pre&gt;

or in Rails:
&lt;pre&gt;
response.headers["X-Sendfile"] = "/path/to/upload.html" 
&lt;/pre&gt;</description>
      <pubDate>Sat, 22 Jul 2006 09:55:30 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:54e5c68a-0bd2-44c4-a436-d7a9328ffc0e</guid>
      <author>jan</author>
      <link>http://blog.lighttpd.net/articles/2006/07/22/mod_proxy_core-got-x-sendfile-support</link>
      <category>X</category>
      <category>Sendfile</category>
      <category>mod_proxy_core</category>
      <trackback:ping>http://blog.lighttpd.net/articles/trackback/1821</trackback:ping>
    </item>
    <item>
      <title>Hash Balancing with mod_proxy_core</title>
      <description>&lt;p&gt;mod_proxy and mod_proxy_core support 3 balancers to spread the load over multiple backends. One of them is Hash balancing which is very good for balancing the load of caching proxies like Squid.&lt;/p&gt;


	&lt;p&gt;If you compare the performance of Hash-Balancing to the classic round-robin balancing you should see a increase of the performance as the backends can use their caches a lot better. With RR each backend has to handle the full &lt;span class="caps"&gt;URL&lt;/span&gt; namespace, with Hash-Balancing only a part. This increases the cache-locality and the overall performance.&lt;/p&gt;
&lt;p&gt;I&amp;#8217;ve taken &lt;a href="http://wikipedia.org/"&gt;wikipedia&lt;/a&gt; as testbed for the hash-balancing:&lt;/p&gt;


&lt;pre&gt;
$SERVER["socket"] == ":1445" {
  proxy-core.balancer = "hash" 
  proxy-core.protocol = "http" 
  proxy-core.backends = ( "wikipedia.org" )
  proxy-core.rewrite-response = (
    "Location" =&amp;gt; ( "^http://en.wikipedia.org/(.*)" =&amp;gt; "http://127.0.0.1:1445/$1" ),
  )
  proxy-core.rewrite-request = (
    "Host" =&amp;gt; ( ".*" =&amp;gt; "en.wikipedia.org" ),
 )
}
&lt;/pre&gt;

	&lt;p&gt;The domain &lt;kbd&gt;wikipedia.org&lt;/kbd&gt; resolves to several IP-addresses:&lt;/p&gt;


&lt;pre&gt;
(trace) resolving wikipedia.org on port 80
(trace) adding 207.142.131.204:80 to the address-pool
(trace) adding 207.142.131.205:80 to the address-pool
(trace) adding 207.142.131.206:80 to the address-pool
(trace) adding 207.142.131.210:80 to the address-pool
(trace) adding 207.142.131.213:80 to the address-pool
(trace) adding 207.142.131.214:80 to the address-pool
(trace) adding 207.142.131.235:80 to the address-pool
(trace) adding 207.142.131.236:80 to the address-pool
(trace) adding 207.142.131.245:80 to the address-pool
(trace) adding 207.142.131.246:80 to the address-pool
(trace) adding 207.142.131.247:80 to the address-pool
(trace) adding 207.142.131.248:80 to the address-pool
(trace) adding 207.142.131.202:80 to the address-pool
(trace) adding 207.142.131.203:80 to the address-pool
&lt;/pre&gt;

	&lt;p&gt;When I request &lt;kbd&gt;http://127.0.0.1:1445/&lt;/kbd&gt; the load-balancer takes the &lt;span class="caps"&gt;URL&lt;/span&gt; hashes it and sends it the one of the backends.&lt;/p&gt;


&lt;pre&gt;
(trace) using hash-balancing: /wiki/Main_Page -&amp;gt; 207.142.131.204:80
(trace) using hash-balancing: /skins-1.5/monobook/main.css -&amp;gt; 207.142.131.204:80
(trace) using hash-balancing: /skins-1.5/common/commonPrint.css -&amp;gt; 207.142.131.213:80
(trace) using hash-balancing: /skins-1.5/common/wikibits.js -&amp;gt; 207.142.131.245:80
(trace) using hash-balancing: /w/index.php -&amp;gt; 207.142.131.206:80
(trace) using hash-balancing: /w/index.php -&amp;gt; 207.142.131.206:80
(trace) using hash-balancing: /w/index.php -&amp;gt; 207.142.131.206:80
(trace) using hash-balancing: /w/index.php -&amp;gt; 207.142.131.206:80
(trace) using hash-balancing: /skins-1.5/monobook/headbg.jpg -&amp;gt; 207.142.131.202:80
(trace) using hash-balancing: /skins-1.5/monobook/bullet.gif -&amp;gt; 207.142.131.245:80
(trace) using hash-balancing: /skins-1.5/common/images/poweredby_mediawiki_88x31.png -&amp;gt; 207.142.131.236:80
(trace) using hash-balancing: /images/wikimedia-button.png -&amp;gt; 207.142.131.203:80
(trace) using hash-balancing: /skins-1.5/monobook/bullet.gif -&amp;gt; 207.142.131.245:80
(trace) using hash-balancing: /skins-1.5/monobook/user.gif -&amp;gt; 207.142.131.202:80
(trace) using hash-balancing: /images/wiki-en.png -&amp;gt; 207.142.131.204:80
&lt;/pre&gt;

	&lt;p&gt;You see that the same &lt;span class="caps"&gt;URL&lt;/span&gt; results in the same address that is connected.&lt;/p&gt;


	&lt;p&gt;If one of the backends goes down, all requests that were meant for that backend are spread over the other backends. If you had 10 backends and 1 goes down, each backend has to server 1/9 URLs of the dead backend.&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;you have &lt;kbd&gt;100 URLs, 10 backends&lt;/kbd&gt;&lt;/li&gt;
		&lt;li&gt;each backend handles &lt;kbd&gt;(100/10) = 10 URLs&lt;/kbd&gt;&lt;/li&gt;
		&lt;li&gt;one backend goes down and its &lt;kbd&gt;10 URLs&lt;/kbd&gt; are spread over the other 9 backends&lt;/li&gt;
		&lt;li&gt;each backend handles now its &lt;kbd&gt;10 URLs as before + (10/9) URLs&lt;/kbd&gt; of the dead backend&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Hash balancing is following the ideas from &lt;a href="http://icp.ircache.net/carp.txt"&gt;http://icp.ircache.net/carp.txt&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Wed, 19 Jul 2006 13:38:52 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:c7479c7b-8743-44e7-8a31-219ec0c623dd</guid>
      <author>jan</author>
      <link>http://blog.lighttpd.net/articles/2006/07/19/hash-balancing-with-mod_proxy_core</link>
      <category>mod_proxy_core</category>
      <category>hash</category>
      <category>load</category>
      <category>balancing</category>
      <trackback:ping>http://blog.lighttpd.net/articles/trackback/1786</trackback:ping>
    </item>
    <item>
      <title>mod_proxy_core commited to svn</title>
      <description>&lt;p&gt;mod_proxy_core just got commited to &lt;span class="caps"&gt;SVN&lt;/span&gt; and is now available to testers.&lt;/p&gt;


&lt;pre&gt;
server.modules = ( ..., "mod_proxy_core", .. )

## works
$HTTP["url"] =~ "^/proxyme/" {
  proxy-core.balancer = "round-robin" 
  proxy-core.protocol = "http" 
  proxy-core.backends = ( "wikipedia.org" )

  ## to be done
  proxy-core.rewrite-response = (
    "Location" =&amp;gt; ( 
      "^http://en.wikipedia.org/(.*)" =&amp;gt; "http://127.0.0.1:1025/$1" ) )
  proxy-core.rewrite-request = (
    "URI" =&amp;gt; (
      "^/proxyme(/.*)" =&amp;gt; "$1" ) )
}
&lt;/pre&gt;
&lt;p&gt;The above config forwards everything from /proxyme/ to wikipeedia.org. It resolves the domain wikipedia.org and is using one of the address to forward the request. As you already see there will be a request and response header rewriter for rewriting Location headers and URIs.&lt;/p&gt;


&lt;h3&gt;What works ?&lt;/h3&gt;

	&lt;ul&gt;
	&lt;li&gt;Round-Robin Load-Balancing&lt;/li&gt;
		&lt;li&gt;Failover of a backend is down&lt;/li&gt;
		&lt;li&gt;&lt;span class="caps"&gt;HTTP&lt;/span&gt; proxying&lt;/li&gt;
		&lt;li&gt;&lt;span class="caps"&gt;HTTP&lt;/span&gt;/1.1&lt;/li&gt;
		&lt;li&gt;Keep-Alive&lt;/li&gt;
	&lt;/ul&gt;


&lt;h3&gt;What is missing&lt;/h3&gt;

	&lt;ul&gt;
	&lt;li&gt;FastCGI, &lt;span class="caps"&gt;SCGI&lt;/span&gt; and &lt;span class="caps"&gt;CGI&lt;/span&gt; backends&lt;/li&gt;
		&lt;li&gt;Header Rewriting&lt;/li&gt;
	&lt;/ul&gt;


&lt;h3&gt;Show me the source, Luke&lt;/h3&gt;

	&lt;p&gt;In the &lt;a href="http://trac.lighttpd.net/trac/browser/branches/lighttpd-merge-1.4.x/src/mod_proxy_core.c"&gt;source-browsers&lt;/a&gt; you can also take a look at the code to see what is going on in there.&lt;/p&gt;</description>
      <pubDate>Tue, 18 Jul 2006 10:06:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:127d2b2f-3d95-48d7-8010-e195c9d77ba9</guid>
      <author>jan</author>
      <link>http://blog.lighttpd.net/articles/2006/07/18/mod_proxy_core-commited-to-svn</link>
      <category>mod_proxy_core</category>
      <trackback:ping>http://blog.lighttpd.net/articles/trackback/1775</trackback:ping>
    </item>
  </channel>
</rss>
