05.05.2013 Views

Programming PHP

Programming PHP

Programming PHP

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Figure 13-2. Squid caching<br />

The relevant part of the Squid configuration file to set up Squid in this manner is:<br />

httpd_accel_host 127.0.0.1<br />

httpd_accel_port 80<br />

httpd_accel_single_host on<br />

httpd_accel_uses_host_header on<br />

Load balancing and redirection<br />

One way to boost performance is to spread the load over a number of machines. A<br />

load-balancing system does this by either evenly distributing the load or sending<br />

incoming requests to the least loaded machine. A redirector is a program that<br />

rewrites incoming URLs, allowing fine-grained control over the distribution of<br />

requests to individual server machines.<br />

Again, there are hardware HTTP redirectors and load-balancers, but redirection and<br />

load balancing can also be done effectively in software. By adding redirection logic to<br />

Squid through something like SquidGuard (http://www.squidguard.org), you can do a<br />

number of things to improve performance.<br />

Figure 13-3 shows how a redirector can load-balance requests either over multiple<br />

backend web servers or across separate Apache instances running on different ports<br />

on the same server.<br />

127.0.0.1:80<br />

Apache<br />

External IP port 80<br />

Squid<br />

127.0.0.1:80<br />

Apache<br />

Figure 13-3. Load balancing with SquidGuard<br />

314 | Chapter 13: Application Techniques<br />

External IP port 80<br />

Squid<br />

127.0.0.1:80<br />

Apache<br />

192.168.0.1:80<br />

Apache<br />

SquidGuard<br />

Redirector<br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!