Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

Load balancing web servers (html code?)

Thread Tools
 
Search this Thread
 
Old 08 February 2007, 02:39 PM
  #1  
Avi
Scooby Regular
Thread Starter
 
Avi's Avatar
 
Join Date: Apr 2001
Location: Manchester
Posts: 5,084
Likes: 0
Received 0 Likes on 0 Posts
Default 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
Old 08 February 2007, 02:45 PM
  #2  
David_Wallis
Scooby Regular
 
David_Wallis's Avatar
 
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
Default

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
Old 08 February 2007, 03:15 PM
  #3  
Avi
Scooby Regular
Thread Starter
 
Avi's Avatar
 
Join Date: Apr 2001
Location: Manchester
Posts: 5,084
Likes: 0
Received 0 Likes on 0 Posts
Default

David

Good idea, but it doesn't seem to load balance, will it only use the secondary address if it can't resolve the first one?
Old 08 February 2007, 03:33 PM
  #4  
stevem2k
Scooby Regular
 
stevem2k's Avatar
 
Join Date: Sep 2001
Location: Kingston ( Surrey, not Jamaica )
Posts: 4,670
Likes: 0
Received 0 Likes on 0 Posts
Default

Apache or IIS(spit)
Old 08 February 2007, 04:49 PM
  #5  
RichB
Scooby Regular
 
RichB's Avatar
 
Join Date: Apr 1999
Location: Bore Knee Muff
Posts: 3,666
Likes: 0
Received 0 Likes on 0 Posts
Default

<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?
Old 08 February 2007, 04:54 PM
  #6  
RichB
Scooby Regular
 
RichB's Avatar
 
Join Date: Apr 1999
Location: Bore Knee Muff
Posts: 3,666
Likes: 0
Received 0 Likes on 0 Posts
Default

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.
Old 08 February 2007, 05:36 PM
  #7  
David_Wallis
Scooby Regular
 
David_Wallis's Avatar
 
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
Default

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 )

Last edited by David_Wallis; 08 February 2007 at 05:37 PM. Reason: a
Old 08 February 2007, 05:37 PM
  #8  
David_Wallis
Scooby Regular
 
David_Wallis's Avatar
 
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
Default

RichB

Load Balancing doesnt mean redundancy, he never asked for redundancy!
Old 08 February 2007, 05:47 PM
  #9  
RichB
Scooby Regular
 
RichB's Avatar
 
Join Date: Apr 1999
Location: Bore Knee Muff
Posts: 3,666
Likes: 0
Received 0 Likes on 0 Posts
Default

Yes I relised that - having reread I see what you mean
Old 09 February 2007, 10:46 AM
  #10  
David_Wallis
Scooby Regular
 
David_Wallis's Avatar
 
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
Default

Old 09 February 2007, 10:57 AM
  #11  
judgejules
Scooby Regular
 
judgejules's Avatar
 
Join Date: Nov 2000
Posts: 1,227
Likes: 0
Received 0 Likes on 0 Posts
Default

Originally Posted by Avi
David

Good idea, but it doesn't seem to load balance, will it only use the secondary address if it can't resolve the first one?
If you're using MS DNS Server then tick in "Enable round robin" under the advanced tab of the properties window for the server. Otherwise adding two records of the same type wont make any difference.

Jules
Old 09 February 2007, 11:49 AM
  #12  
Avi
Scooby Regular
Thread Starter
 
Avi's Avatar
 
Join Date: Apr 2001
Location: Manchester
Posts: 5,084
Likes: 0
Received 0 Likes on 0 Posts
Default

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
Old 09 February 2007, 01:01 PM
  #13  
stevem2k
Scooby Regular
 
stevem2k's Avatar
 
Join Date: Sep 2001
Location: Kingston ( Surrey, not Jamaica )
Posts: 4,670
Likes: 0
Received 0 Likes on 0 Posts
Default

if you are on a M$ environment why not use WLBS ?
Old 09 February 2007, 03:25 PM
  #14  
David_Wallis
Scooby Regular
 
David_Wallis's Avatar
 
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
Default

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
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Darrell@Scoobyworx
Trader Announcements
26
30 January 2024 01:27 PM
shorty87
Full Cars Breaking For Spares
19
22 December 2015 11:59 AM
LSherratt
Non Scooby Related
20
28 September 2015 12:04 AM
sivo
ScoobyNet General
12
26 September 2015 12:34 PM
Littleted
Computer & Technology Related
0
25 September 2015 08:44 AM



Quick Reply: Load balancing web servers (html code?)



All times are GMT +1. The time now is 09:13 AM.