Penguin
Blame: ModBackhandExample
EditPageHistoryDiffInfoLikePages
Annotated edit history of ModBackhandExample version 7, including all changes. View license author blame.
Rev Author # Line
1 PhilMurray 1 This is simply one of many different configurations of a ModBackhand cluster and is how I currently have mine setup.
2
3 In this configuration we have a single machine at the front that has a stripped down version of Apache that will do all the load balancing and not service requests itself. Behind the balancer is the cluster of application servers, these will have the heavier Apache (ie, PHP, mod_perl, mod_jk/Tomcat) and do all the actual serving of requests.
4
5 [http://www.nevada.net.nz/~pmurray/cluster.png]
6
7 In this example though we have a single point of failure, which is the balancer, this can be fixed by having a second backup balancer ready to take over (see HighAvailability).
8
9 !!Step 1: Configure Apache on ALL servers with mod_backhand
10
11 (Note: mod_backhand will only work on Unix machines with Apache 1.3.x)
12
13 !FreeBSD
14 Make sure your ports collection is up to date and then:
15
16 cd /usr/ports/www/mod_backhand
17 make install
18
19 !Debian
20
7 MattBrown 21 If you are using apache one you can ''apt-get install libapache_mod_backhand'', unfortunately mod_backhand does not seem to be packaged for Apache2 in sarge.
1 PhilMurray 22
23 !Insert your OS/Distro here
24
25 After it's compiled/installed you need to make sure it's enabled in Apache, check the following lines appear somewhere in your httpd.conf
26
27 !LoadModule backhand_module libexec/apache/mod_backhand.so
2 PhilMurray 28 !AddModule mod_backhand.c
29
30 Make sure the !AddModule line goes above any other 3rd party extension !AddModule lines (like PHP/mod_jk/mod_perl)
1 PhilMurray 31
32 !!Step 2: Configure your balancer
33
34 <!IfModule mod_backhand.c>
35 !UnixSocketDir /var/backhand/
36
37 Make sure /var/backhand exists and is writeable by the user Apache runs as
38
39 !MulticastStats 10.58.4.1 239.255.221.20:4445,1
40
41 This line tells ModBackhand we want to advertise ourselves as 10.58.4.1 to the multicast address 239.255.221.20 port 4445 with a timeout of 1 second
42
43 !AcceptStats 10.58.4.0/24
44
45 Because all ModBackhand enabled servers will broadcast information we want to know which information we should listen to, so accept messages from our backend servers on the network 10.58.4.0/24
46
47 </!IfModule>
48
49 Having a <Directory> block will enable ModBackhand balancing for all requests to files in that directory, it doesn't have to be your DocumentRoot and it can also be a <Files *.php|*.asp> or <Location> block. You can practically balance anything Apache will understand.
50
51 <Directory /usr/local/www/htdocs/>
52 !AllowOverride None
53 Options None
54 Order allow,deny
55 Allow from all
56
57 Backhand removeSelf
58
59 Because this server is simply a balancer we don't want to consider ourself as a valid server when selecting a candidate
60
61 Backhand byAge 6
62
63 We don't want to send a request to a server we haven't heard from in 6 seconds. This provies some fault tolerance as the request won't be directed to a dead candidate.
64
65 Backhand byRandom
66
67 Randomly choose a server from remaining pool.
68
69 Backhand byLogWindow
70
71 This does something I don't quite understand yet, but it's good to have
72
73 Backhand byLoad
74
75 Decide which candidate is best from the load on that server
76
77 </Directory>
78
79 If your balancer is serving multiple sites, put the above in a <VirtualHost> block, otherwise it doesn't matter. These are not the only candidancy functions available, for a list of the rest see the ModBackhand website.
80
81 !!Step 3: Configuring backend servers
82
83 First we enable ModBackhand
84
85 <!IfModule mod_backhand.c>
86 !UnixSocketDir /var/backhand/
87 !MulticastStats 10.58.4.2 239.255.221.20:4445,1
4 PhilMurray 88 !AcceptStats 10.58.4.0/24
1 PhilMurray 89 </!IfModule>
90
91 Again, make sure /var/backhand exists and is writeable by the Apache user. These options can also go in a <VirtualHost> block or not. However! Because ModBackhand is proxying these requests you CANNOT use NameBased Virtual Hosting on sites that are part of the cluster. You CAN use IP Based Virtual Hosting which means you would need a block (like above) for each !VirtualHost with a different adress for !MulticastStats. Don't forget to make sure your !DocumentRoot is right for this !VirtualHost or the general configuration.
92
93 !!Step 4: Start all your Apache servers
94
95 The cluster should be working! If you want to see the status of your cluster, put the following in your balancers httpd.conf
96
3 PhilMurray 97 <!VirtualHost 10.58.4.1>
1 PhilMurray 98 !DocumentRoot /usr/local/www/data
99 <Location "/backhand/">
100 !SetHandler backhand-handler
101 </Location>
102 </!VirtualHost>
103
3 PhilMurray 104 Then browse to http://10.58.4.1/backhand/ and it'll give you a status map.
1 PhilMurray 105
106 You now have a clustered website, but you still have storage and a database to worry about!