mod_rewrite also allows us to fetch pass through instructions from a program. Now consider this:
RewriteMap    lb      prg:/path/to/lb.pl
RewriteRule   ^/(.+)$ ${lb:$1}           [P,L]
Where lb.pl is a program that looks like this:
$| = 1;
while (<STDIN>) {
   my $server=best_server($_);
   print "http://$server/$_";
}

sub best_server {
   # do something that is not too slow
   my $r=shift;
}
Presumably best_server() does something simple like walk through a list of back end servers or something more sophisticated like a lookup in Berkeley DB hash to determine the most appropriate server for that request. Whatever it does, make sure it does it fast lest the server is hung on a lookup process that is slower than the request rate!
Slide 11 of 27 Contents
  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
www.arachna.com > Educational Resources > Conference Presentations

spidaman
© 1999-2008 Ian Kallen | Copyright Notice