Load balancing web servers (html code?)
#1
Scooby Regular
Thread Starter
Load balancing web servers (html code?)
I have 2 web servers, both running an identical app. I have a link on the homepage that points to http://server2 and a link in everyone's start menu that points to http://server1
Looking at the logs, server1 is hardly being used
Can anyone suggest a simple bit of code that will randomise which server they are directed when they click the link on the homepage?
Thanks
Avi
Looking at the logs, server1 is hardly being used
Can anyone suggest a simple bit of code that will randomise which server they are directed when they click the link on the homepage?
Thanks
Avi
#2
Scooby Regular
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like
on
1 Post
create a dns entry called app for example with ip of server 1
then do the same entry but with the ip of server 2
It should then round robin load balance, just depends whether you need to maintain session state and support ssl.
David
then do the same entry but with the ip of server 2
It should then round robin load balance, just depends whether you need to maintain session state and support ssl.
David
#5
Scooby Regular
Join Date: Apr 1999
Location: Bore Knee Muff
Posts: 3,666
Likes: 0
Received 0 Likes
on
0 Posts
<a href="http://server<?php echo rand(1,2);?>"/>To our home page</a>
As a crude solution.
David - Does that actually work? - Can you have multiple www CNAMEs with different IP addresses OR do you have to have one CNAME called www - pointing at the domain and then create multiple A records with different IP addresses?
As a crude solution.
David - Does that actually work? - Can you have multiple www CNAMEs with different IP addresses OR do you have to have one CNAME called www - pointing at the domain and then create multiple A records with different IP addresses?
#6
Scooby Regular
Join Date: Apr 1999
Location: Bore Knee Muff
Posts: 3,666
Likes: 0
Received 0 Likes
on
0 Posts
surely it will do a DNS request and then if it can't get to the server it resolved to it would fail rather than looking up again...
I could understand that 10 requests might yield different servers IPs as per the list of A records but not act in a 'redundancy' type manner.
I could understand that 10 requests might yield different servers IPs as per the list of A records but not act in a 'redundancy' type manner.
#7
Scooby Regular
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like
on
1 Post
I never said use a cname
But theres no reason why you cant use an A record for the virtual / internal name.
Do a nslookup on the host and just keep running it and they should swap (or rotate like round robin style )
But theres no reason why you cant use an A record for the virtual / internal name.
Do a nslookup on the host and just keep running it and they should swap (or rotate like round robin style )
Last edited by David_Wallis; 08 February 2007 at 05:37 PM. Reason: a
Trending Topics
#11
Jules
#12
Scooby Regular
Thread Starter
Ok guys, i have decided to use asp to randomise the server selection which looks like it will work quite well
<%
Dim r
Call Randomize()
r = Rnd()
If (r <= 0.5) Then
Response.Redirect "http://pacsweb2/amI/html"
Else
Response.Redirect "http://pacsweb1/amI/html"
End If
%>
Thanks for your help with this.
Avi
<%
Dim r
Call Randomize()
r = Rnd()
If (r <= 0.5) Then
Response.Redirect "http://pacsweb2/amI/html"
Else
Response.Redirect "http://pacsweb1/amI/html"
End If
%>
Thanks for your help with this.
Avi
#14
Scooby Regular
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like
on
1 Post
If using AD then enable round robin should be enabled by default
PS to do it right click the server in DNS mmc and do properties.
David
PS to do it right click the server in DNS mmc and do properties.
David
Thread
Thread Starter
Forum
Replies
Last Post
shorty87
Full Cars Breaking For Spares
19
22 December 2015 11:59 AM