Solved

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

Posted on 2008-10-12
12
384 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
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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é.
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

911 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

22 Experts available now in Live!

Get 1:1 Help Now