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 Feb 8, 2007 | 02:39 PM
  #1  
Avi's Avatar
Avi
Thread Starter
Scooby Regular
 
Joined: Apr 2001
Posts: 5,084
Likes: 0
From: Manchester
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
Reply
Old Feb 8, 2007 | 02:45 PM
  #2  
David_Wallis's Avatar
David_Wallis
Scooby Regular
 
Joined: Nov 2001
Posts: 15,239
Likes: 1
From: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
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
Reply
Old Feb 8, 2007 | 03:15 PM
  #3  
Avi's Avatar
Avi
Thread Starter
Scooby Regular
 
Joined: Apr 2001
Posts: 5,084
Likes: 0
From: Manchester
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?
Reply
Old Feb 8, 2007 | 03:33 PM
  #4  
stevem2k's Avatar
stevem2k
Scooby Regular
 
Joined: Sep 2001
Posts: 4,670
Likes: 0
From: Kingston ( Surrey, not Jamaica )
Default

Apache or IIS(spit)
Reply
Old Feb 8, 2007 | 04:49 PM
  #5  
RichB's Avatar
RichB
Scooby Regular
 
Joined: Apr 1999
Posts: 3,666
Likes: 0
From: Bore Knee Muff
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?
Reply
Old Feb 8, 2007 | 04:54 PM
  #6  
RichB's Avatar
RichB
Scooby Regular
 
Joined: Apr 1999
Posts: 3,666
Likes: 0
From: Bore Knee Muff
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.
Reply
Old Feb 8, 2007 | 05:36 PM
  #7  
David_Wallis's Avatar
David_Wallis
Scooby Regular
 
Joined: Nov 2001
Posts: 15,239
Likes: 1
From: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
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; Feb 8, 2007 at 05:37 PM. Reason: a
Reply
Old Feb 8, 2007 | 05:37 PM
  #8  
David_Wallis's Avatar
David_Wallis
Scooby Regular
 
Joined: Nov 2001
Posts: 15,239
Likes: 1
From: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Default

RichB

Load Balancing doesnt mean redundancy, he never asked for redundancy!
Reply
Old Feb 8, 2007 | 05:47 PM
  #9  
RichB's Avatar
RichB
Scooby Regular
 
Joined: Apr 1999
Posts: 3,666
Likes: 0
From: Bore Knee Muff
Default

Yes I relised that - having reread I see what you mean
Reply
Old Feb 9, 2007 | 10:46 AM
  #10  
David_Wallis's Avatar
David_Wallis
Scooby Regular
 
Joined: Nov 2001
Posts: 15,239
Likes: 1
From: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Default

Reply
Old Feb 9, 2007 | 10:57 AM
  #11  
judgejules's Avatar
judgejules
Scooby Regular
 
Joined: Nov 2000
Posts: 1,227
Likes: 0
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
Reply
Old Feb 9, 2007 | 11:49 AM
  #12  
Avi's Avatar
Avi
Thread Starter
Scooby Regular
 
Joined: Apr 2001
Posts: 5,084
Likes: 0
From: Manchester
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
Reply
Old Feb 9, 2007 | 01:01 PM
  #13  
stevem2k's Avatar
stevem2k
Scooby Regular
 
Joined: Sep 2001
Posts: 4,670
Likes: 0
From: Kingston ( Surrey, not Jamaica )
Default

if you are on a M$ environment why not use WLBS ?
Reply
Old Feb 9, 2007 | 03:25 PM
  #14  
David_Wallis's Avatar
David_Wallis
Scooby Regular
 
Joined: Nov 2001
Posts: 15,239
Likes: 1
From: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
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
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Darrell@Scoobyworx
Trader Announcements
26
Jan 30, 2024 01:27 PM
shorty87
Full Cars Breaking For Spares
19
Dec 22, 2015 11:59 AM
LSherratt
Non Scooby Related
20
Sep 28, 2015 12:04 AM
sivo
ScoobyNet General
12
Sep 26, 2015 12:34 PM
Littleted
Computer & Technology Related
0
Sep 25, 2015 08:44 AM




All times are GMT +1. The time now is 12:10 PM.