Solved

Using 2 linux boxs with dynamic Ip to set up Load balancing Servers

Posted on 2008-10-12
12
383 Views
Last Modified: 2013-12-15
Hi all Expert!

I have a difficult question, I can't find solution though Google or any forum, so need your helo :D
I hav a website that running on a shared hosting, but now I want to use it (shared hosting) just for redirect from http://domain.com to http://website.domain.com. Script using to redirect count how many request per time, then it redirect request to 1 of 2 linux webservers or both of them.

Problem is I already setup two web server, but I used dynamic IP, not statis IP. Can I set up Load Balance using 2 Linux Boxs with dynamic IP? and how? I'm running Ubuntu on both servers, using Apache 2.x.

Thank you for all of ur help!

-n
0
Comment
Question by:binguyendl
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 48

Expert Comment

by:Tintin
ID: 22698627
Where are the two web servers you setup running?  Are they also on shared hosting?

Given your limitations of shared hosting and dynamic IP addresses, probably the best load balancing you can hope for is to configure DNS round robin (if possible)
0
 
LVL 20

Expert Comment

by:edster9999
ID: 22706443
By dynamic do you mean you have dhcp giving out internal addresses or you are using dynamic public addresses that change ?

If it is public ones then you can get round this using a service like no-ip.com
If it is internal addresses then reconfigure them as fixed.

You can have a single server that forwards to 2 different servers either in the same rack or elsewhere.  This does howver give you a single point of fail and means that this box still has to process every request so it is not really load balancing.
0
 
LVL 1

Author Comment

by:binguyendl
ID: 22709219
I already setup 2 servers, using dynamic public Ip, 2 servers is public and anyone can access using http://server1.com and http://server2.com. This is 2 servers, not shared hosting, I use dyndns.com dynamic dns.

Now I don't know how to use these servers to setup Load balancing, maybe when user type in address bar: http://mysite.com, user will visite http://mysite.com what hosted in one shared hosting, I user a php script to count how many request per time, then it redirect requests to 1 of 2 linux webservers or both of them.

thanks!

0
 
LVL 20

Expert Comment

by:edster9999
ID: 22709733
Best bet.... get 2 fixed IPs.  It shouldn't cost much and then you can do simple load balancing very easily by doing a round robin DNS.
You can do this with dyndns.com (only with fixed IPs) or using your own dns service.

If you really can not do this then you have two options.

Option 1.   Have a third box as the landing sote and this then forwards to the other two boxes.  This will be expensive but gives you real load balancing and makes it compatible (see below).  This could be a server or a dedicated hardware load balancer.

Option 2.   Have one of the boxes serve as the landing site.  This will be on port 80 (or 443 if you are doing SSL).  When it lands there you use a script to redirect to the two boxes.   You will then need to move the real web server to a non standard port like 88 or 8080.  This will means one or two people will not be able to get to the site as they are behind proxies or using devices that will not work off port 80 (like some phones).  It also doesn't look as professional.
You could let the server go and get the traffic and pass it on using the first address but then you have lost all loadbalancing as this box is doing work for every request.

0
 
LVL 29

Expert Comment

by:Michael W
ID: 22712412
0
 
LVL 20

Expert Comment

by:edster9999
ID: 22712550
as stated above they will let you do it with static addresses but not dynamic ones
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 1

Author Comment

by:binguyendl
ID: 23115832
there is no solution with dynamic IP?
0
 
LVL 20

Expert Comment

by:edster9999
ID: 23115883
No not a real solution.  You should not use dynamic addesses for any hosting really.  If it is a little test you can use dynamic addresses just to get running but as you are talking about load balancing it is obviously more than a test so upgrade to real static IPs.  It really is the only path.
0
 
LVL 29

Expert Comment

by:Michael W
ID: 23126253
Shared hosting solutions weren't designed for high availability, load balancing or clustering solutions. If/when you are growing to that level of inbound traffic, I recommend to start looking at dedicated, co-location hosting sites where you aren't 'sharing' a server environment with someone else. Then you can look at Linux platforms like Red Hat Enterprise 5.x or CentOS 5.x which were designed for these types of environments.
0
 
LVL 1

Author Comment

by:binguyendl
ID: 23129662
You don't understand. I already had two servers which are running Linux, and every one can access to these boxes through Internet + 1 shared hosting.

I want this shared hosting act as a bridge to redirect requests to 1 or both 2 Linux Servers ( this 2 servers has dynamic "public IP").

@edster9999: Thank you, and explain my trouble:
I use everydns, www1.domain.com points to server1, www2.domain.com points to server2. I update dynamic IP by my own shell script, it's working well.

All I want is Load balancing between 2 servers using "Dynamic IP".

0
 
LVL 20

Accepted Solution

by:
edster9999 earned 500 total points
ID: 23129927
Well.... If you have the two servers up and running and you are handling the dynamic scripting for the DNS then the changes are not done at that end at all.  Those two servers just sit there waiting for requests.
The clever stuff should be done at the shared host.

Do you want people to see the other URLs ?
If I go to www.domain.com and get to the shared host... do you want the url to stay the same at the top but the content to come from one of the other boxes or do you want it to change ?

If you want it to change then it is very easy to setup.  If you really want to land on that server first to count stats then you have an index page that updates the stats (adds one to a database maybe) and then does a 301 page redirection to www1.domain or www2.domain either by random or by counting connections etc.

Send out something like :
Header( "HTTP/1.1 301 Moved Permanently" );
if ($serverToUse == "1") {
    Header( "Location: http://www1.domain.com" );
} else {
    Header( "Location: http://www2.domain.com" );
}

Now if you are not so worried about counting stats you could do this far easier by using round robin cnames.  This would remove the need to have the shared servers at all -
http://content.websitegear.com/article/load_balance_dns.htm

If you don't want them to see the URL change then you could have the page on the server open an iframe with the url www1.domain.com or www2.
0
 
LVL 1

Author Comment

by:binguyendl
ID: 23185467
Maybe It's my solution. THank you!
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now