From 49fd4acabbb298c03652226d54add3245b93ce18 Mon Sep 17 00:00:00 2001 From: Rich Bowen Date: Tue, 3 Nov 2009 06:08:36 +0000 Subject: [PATCH] Build Colm's 'sharding' recipe. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@832309 13f79535-47bb-0310-9956-ffa450edef68 --- docs/manual/rewrite/rewrite_guide.html.en | 69 ++++++++++------------- 1 file changed, 29 insertions(+), 40 deletions(-) diff --git a/docs/manual/rewrite/rewrite_guide.html.en b/docs/manual/rewrite/rewrite_guide.html.en index 1d52e5730c..3ab6fb6d00 100644 --- a/docs/manual/rewrite/rewrite_guide.html.en +++ b/docs/manual/rewrite/rewrite_guide.html.en @@ -52,7 +52,7 @@
  • Time-Dependent Rewriting
  • Proxy Deny
  • External Rewriting Engine
  • -
  • Web Cluster with Consistent URL Space
  • +
  • URL-based sharding accross multiple backends
  • Structured Homedirs
  • Browser Dependent Content
  • Dynamic Mirror
  • @@ -401,9 +401,16 @@ RewriteRule ^foo\.html$ foo.night.html

    This provides the content of foo.day.html under the URL foo.html from - 07:00-19:00 and at the remaining time the + 07:01-18:59 and at the remaining time the contents of foo.night.html. Just a nice feature for a homepage...

    + +
    mod_cache, intermediate proxies + and browsers may each cache responses and cause the either page to be + shown outside of the time-window configured. + mod_expires may be used to control this + effect.
    + @@ -500,7 +507,7 @@ while (<>) {
    top
    -

    Web Cluster with Consistent URL Space

    +

    URL-based sharding accross multiple backends

    @@ -508,67 +515,49 @@ while (<>) {
    Description:
    -

    We want to create a homogeneous and consistent URL - layout across all WWW servers on an Intranet web cluster, i.e., - all URLs (by definition server-local and thus - server-dependent!) become server independent! - What we want is to give the WWW namespace a single consistent - layout: no URL should refer to - any particular target server. The cluster itself - should connect users automatically to a physical target - host as needed, invisibly.

    +

    A common technique for distributing the burden of + server load or storage space is called "sharding". + When using this method, a front-end server will use the + url to consistently "shard" users or objects to seperate + backend servers.

    Solution:
    -

    First, the knowledge of the target servers comes from - (distributed) external maps which contain information on - where our users, groups, and entities reside. They have the - form:

    +

    A mapping is maintained, from users to target servers, in + external map files. They look like:

    -user1  server_of_user1
    -user2  server_of_user2
    +user1  physical_host_of_user1
    +user2  physical_host_of_user2
     :      :
     
    -

    We put them into files map.xxx-to-host. - Second we need to instruct all servers to redirect URLs - of the forms:

    +

    We put this into a map.users-to-hosts file. The + aim is to map;

    -/u/user/anypath
    -/g/group/anypath
    -/e/entity/anypath
    +/u/user1/anypath
     

    to

    -http://physical-host/u/user/anypath
    -http://physical-host/g/group/anypath
    -http://physical-host/e/entity/anypath
    +http://physical_host_of_user1/u/user/anypath
     
    -

    when any URL path need not be valid on every server. The - following ruleset does this for us with the help of the map - files (assuming that server0 is a default server which - will be used if a user has no entry in the map):

    +

    thus every URL path need not be valid on every backend physical + host. The following ruleset does this for us with the help of the map + files assuming that server0 is a default server which will be used if + a user has no entry in the map):

     RewriteEngine on
     
    -RewriteMap      user-to-host   txt:/path/to/map.user-to-host
    -RewriteMap     group-to-host   txt:/path/to/map.group-to-host
    -RewriteMap    entity-to-host   txt:/path/to/map.entity-to-host
    -
    -RewriteRule   ^/u/([^/]+)/?(.*)   http://${user-to-host:$1|server0}/u/$1/$2
    -RewriteRule   ^/g/([^/]+)/?(.*)  http://${group-to-host:$1|server0}/g/$1/$2
    -RewriteRule   ^/e/([^/]+)/?(.*) http://${entity-to-host:$1|server0}/e/$1/$2
    +RewriteMap      users-to-hosts   txt:/path/to/map.users-to-hosts
     
    -RewriteRule   ^/([uge])/([^/]+)/?$          /$1/$2/.www/
    -RewriteRule   ^/([uge])/([^/]+)/([^.]+.+)   /$1/$2/.www/$3\
    +RewriteRule   ^/u/([^/]+)/?(.*)   http://${users-to-hosts:$1|server0}/u/$1/$2
     
    -- 2.40.0