1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.21">
<TITLE>SQUID Frequently Asked Questions: httpd-accelerator mode</TITLE>
<LINK HREF="FAQ-21.html" REL=next>
<LINK HREF="FAQ-19.html" REL=previous>
<LINK HREF="FAQ.html#toc20" REL=contents>
</HEAD>
<BODY>
<A HREF="FAQ-21.html">Next</A>
<A HREF="FAQ-19.html">Previous</A>
<A HREF="FAQ.html#toc20">Contents</A>
<HR>
<H2><A NAME="s20">20.</A> <A HREF="FAQ.html#toc20">httpd-accelerator mode</A></H2>
<H2><A NAME="what-is-httpd-accelerator"></A> <A NAME="ss20.1">20.1</A> <A HREF="FAQ.html#toc20.1">What is the httpd-accelerator mode?</A>
</H2>
<P>Occasionally people have trouble understanding accelerators and
proxy caches, usually resulting from mixed up interpretations of
"incoming" and ``outgoing" data. I think in terms of requests (i.e.,
an outgoing request is from the local site out to the big bad
Internet). The data received in reply is incoming, of course.
Others think in the opposite sense of ``a request for incoming data".</P>
<P>An accelerator caches incoming requests for outgoing data (i.e.,
that which you publish to the world). It takes load away from your
HTTP server and internal network. You move the server away from
port 80 (or whatever your published port is), and substitute the
accelerator, which then pulls the HTTP data from the ``real"
HTTP server (only the accelerator needs to know where the real
server is). The outside world sees no difference (apart from an
increase in speed, with luck).</P>
<P>Quite apart from taking the load of a site's normal web server,
accelerators can also sit outside firewalls or other network
bottlenecks and talk to HTTP servers inside, reducing traffic across
the bottleneck and simplifying the configuration. Two or more
accelerators communicating via ICP can increase the speed and
resilience of a web service to any single failure.</P>
<P>The Squid redirector can make one accelerator act as a single
front-end for multiple servers. If you need to move parts of your
filesystem from one server to another, or if separately administered
HTTP servers should logically appear under a single URL hierarchy,
the accelerator makes the right thing happen.</P>
<P>If you wish only to cache the ``rest of the world" to improve local users
browsing performance, then accelerator mode is irrelevant. Sites which
own and publish a URL hierarchy use an accelerator to improve other
sites' access to it. Sites wishing to improve their local users' access
to other sites' URLs use proxy caches. Many sites, like us, do both and
hence run both.</P>
<P>Measurement of the Squid cache and its Harvest counterpart suggest an
order of magnitude performance improvement over CERN or other widely
available caching software. This order of magnitude performance
improvement on hits suggests that the cache can serve as an httpd
accelerator, a cache configured to act as a site's primary httpd server
(on port 80), forwarding references that miss to the site's real httpd
(on port 81).</P>
<P>In such a configuration, the web administrator renames all
non-cachable URLs to the httpd's port (81). The cache serves
references to cachable objects, such as HTML pages and GIFs, and
the true httpd (on port 81) serves references to non-cachable
objects, such as queries and cgi-bin programs. If a site's usage
characteristics tend toward cachable objects, this configuration
can dramatically reduce the site's web workload.</P>
<P>Note that it is best not to run a single <EM>squid</EM> process as
both an httpd-accelerator and a proxy cache, since these two modes
will have different working sets. You will get better performance
by running two separate caches on separate machines. However, for
compatability with how administrators are accustomed to running
other servers that provide both proxy and Web serving capability
(eg, CERN), the Squid supports operation as both a proxy and
an accelerator if you set the <CODE>httpd_accel_with_proxy</CODE>
variable to <CODE>on</CODE> inside your <EM>squid.conf</EM>
configuration file.</P>
<H2><A NAME="ss20.2">20.2</A> <A HREF="FAQ.html#toc20.2">How do I set it up?</A>
</H2>
<P>First, you have to tell Squid to listen on port 80 (usually), so set the 'http_port'
option:
<PRE>
http_port 80
</PRE>
</P>
<P>Next, you need to move your normal HTTP server to another port and/or
another machine. If you want to run your HTTP server on the same
machine, then it can not also use port 80 (except see the next FAQ entry
below). A common choice is port 81. Configure squid as follows:
<PRE>
httpd_accel_host localhost
httpd_accel_port 81
</PRE>
Alternatively, you could move the HTTP server to another machine and leave it
on port 80:
<PRE>
httpd_accel_host otherhost.foo.com
httpd_accel_port 80
</PRE>
</P>
<P>You should now be able to start Squid and it will serve requests as a HTTP server.</P>
<P>If you are using Squid has an accelerator for a virtual host system, then you
need to specify
<PRE>
httpd_accel_host virtual
</PRE>
</P>
<P>Finally, if you want Squid to also accept <EM>proxy</EM> requests (like it used to
before you turned it into an accelerator), then you need to enable this option:
<PRE>
httpd_accel_with_proxy on
</PRE>
</P>
<H2><A NAME="ss20.3">20.3</A> <A HREF="FAQ.html#toc20.3">When using an httpd-accelerator, the port number for redirects is wrong</A>
</H2>
<P>Yes, this is because you probably moved your real httpd to port 81. When
your httpd issues a redirect message (e.g. 302 Moved Temporarily), it knows
it is not running on the standard port (80), so it inserts <EM>:81</EM> in the
redirected URL. Then, when the client requests the redirected URL, it
bypasses the accelerator.</P>
<P>How can you fix this?</P>
<P>One way is to leave your httpd running on port 80, but bind the httpd
socket to a <EM>specific</EM> interface, namely the loopback interface.
With
<A HREF="http://www.apache.org/">Apache</A> you can do it
like this in <EM>httpd.conf</EM>:
<PRE>
Port 80
BindAddress 127.0.0.1
</PRE>
Then, in your <EM>squid.conf</EM> file, you must specify the loopback address
as the accelerator:
<PRE>
httpd_accel_host 127.0.0.1
httpd_accel_port 80
</PRE>
</P>
<P>Note, you probably also need to add an <EM>/etc/hosts</EM> entry
of 127.0.0.1 for your server hostname. Otherwise, Squid may
get stuck in a forwarding loop.</P>
<HR>
<A HREF="FAQ-21.html">Next</A>
<A HREF="FAQ-19.html">Previous</A>
<A HREF="FAQ.html#toc20">Contents</A>
</BODY>
</HTML>
|