Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Load balance and LEB
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Load balance and LEB

joshuatlyjoshuatly Member
edited June 2012 in Help

Hey got some question. I run a site where I serve pdf file download. Im planning to have the files serve from several server to avoid the issue of having one server on a node down, and everyone cant download the file.
What is the easiest way to do it? (I dont have much knowledge about sysadmin and networking yet)

  1. Provide multiple download links, and make them like: fs1.domain.com fs2.domain.com
  2. Or how can i use one download link and load balance them between a few boxes?
    Whats the requirement of doing load balancing? Minimum how many box should i have? what is the ram requirement?
    Im mainly using lowendbox, so please advice.
    Thanks

Comments

  • Easiest way is to use roundrobin DNS. Simply add all of your IPs for the VPS under the same entry for DNS with short TTLs.

    It's not perfect as if one does go down there will be a short time before the changes propagate; however, its cheap and works for most uses.

  • KairusKairus Member

    @joshuatly said: Provide multiple download links, and make them like: fs1.domain.com fs2.domain.com

    Is probably the easiest. You can just have your script (PHP I assume), spit out a different download link at random, should be sufficient. You can add some checks that run on a cron and check if a server is up or down, and have a column in a SQL table marking whether or not the script should use that server. That's how I would do it at least, probably not the most elegant.

  • NickWNickW Member

    Round robin DNS is a great low end solution for this as SharedHost pointed out.

    Create a subdomain such as download.example.com and give it A records for each of the IPs of the boxes in the download cluster. Forget what Shared host said about propagation though. There should be no downtime if one of them goes down, it will just be slower on first connect as it chooses a different server from the round robin. You should set a fairly low TTL though and actively manaage which boxes are up and down in the roubd robin list.

    You set up each of the download boxes to serve from download.example.com as normal.

  • klikliklikli Member

    @joshuatly said: avoid the issue of having one server on a node down, and everyone cant download the file.

    Load balancing may be part of the answer only. What you need is High Availability in exact.

  • CloudxtnyHostCloudxtnyHost Member, Host Rep

    I'd buy some lowend VPS and setup pdns cluster.

    With Powerdns you can then do things like http checks on multiple www. A records.

    If the ping of a vps goes down Powerdns can automatically remove that A record from the dns and leave the remaining working one's. When the http comes back on the server it'lll automatically re-add it.

  • edited June 2012

    @Kairus said: Is probably the easiest. You can just have your script (PHP I assume), spit out a different download link at random, should be sufficient. You can add some checks that run on a cron and check if a server is up or down, and have a column in a SQL table marking whether or not the script should use that server. That's how I would do it at least, probably not the most elegant.

    The only issue with this is there is a single point of failure. If the main site is not available for whatever reason none of the download links are accessible.

    Depending on budget you could set up a load balanced situation. Have your webservers behind two load balancers that make use of heartbeat to ensure that both load balancers are up and if not the other takes over.

  • NanoG6NanoG6 Member

    @httpzoom said: I'd buy some lowend VPS and setup pdns cluster.

    With Powerdns you can then do things like http checks on multiple www. A records.

    If the ping of a vps goes down Powerdns can automatically remove that A record from the dns and leave the remaining working one's. When the http comes back on the server it'lll automatically re-add it.

    Do you have any tutorial or link about it? Currently I also have pdns boxes with mysql replication

  • Geoscaling (free) and Edgedirector (dirt cheap) can do uptime-based failover and geolocation stuff.

    Geoscaling's neat Smart Subdomain stuff can do load balancing based on load averages and all sorts of things.

  • miTgiBmiTgiB Member

    @ShardHost said: Easiest way is to use roundrobin DNS. Simply add all of your IPs for the VPS under the same entry for DNS with short TTLs.

    Since it seems this thread is going deeper into the worst possible solution, let me ask this, what do you do when your DNS is cached at some crappy ISP that ignores TTL, as in 90% of the cable providers?

  • rds100rds100 Member

    @miTgiB blame it on the crappy ISP that doesn't honor DNS TTL and move on? ;-)

  • edited June 2012

    @miTgiB said: Since it seems this thread is going deeper into the worst possible solution, let me ask this, what do you do when your DNS is cached at some crappy ISP that ignores TTL, as in 90% of the cable providers?

    Its not the best way and yes TTLs are not honoured as they should be; however it is a simple way to achieve it and he has a number of other alternatives available here

  • miTgiBmiTgiB Member

    @rds100 said: blame it on the crappy ISP that doesn't honor DNS TTL and move on? ;-)

    And you have a box full of tickets to respond to now for end users unable to use whatever resource you were making available. I know you are poking fun at this, but I get so frustrated when I see a terrible idea and people running with it.

  • upfreakupfreak Member
    edited June 2012

    there are obviously many ways to do this. my take would be
    step 1 : choose how many lebs you want to act as download server and create A records to fs1.domain fs2.domain etc.,
    step 2: select a reliable/cloud hosting to act as your download redirector ( appspot would be fine and is free)
    step 3a: run a client side javascript (possibly ajax ) which pings all your fs1-fs3 and push the download request to that server via header redirect
    optionally you also make this a server side request ( which checks if the download server is available before pushing the header redirect) This would however not consider the shortest ping to the client.

  • yomeroyomero Member

    Question.
    If via DNS is the easiest... there is another way? o_O

  • NickWNickW Member

    @miTgiB said: Since it seems this thread is going deeper into the worst possible solution, let me ask this, what do you do when your DNS is cached at some crappy ISP that ignores TTL, as in 90% of the cable providers?

    If you don't see it as a viable solution then you are incredibly misinformed.

    1) All modern ISPs in this day and age do honour TTLs. Please show me one that doesn't provided the TTL isn't something very low such as 1 s (but most will probably stull honour it).

    2) All DNS servers/forwarders/recursors give the client all of the IP addresses in the round robin. If you set a 3 A records for rr.example.com of 1.1.1.1, 2.2.2.2 and 3.3.3.3 then the web broswer will see all of these records, not just one randomly selected one. The browser will try the first on the list, and if it fails move on to the next. All modern browsers will do this, if Mozilla could figure it out in 1998 (source: http://www-archive.mozilla.org/docs/netlib/dns.html) then I dare say all browsers can figure this out now. Modern browsers will remember which one ended up working and use it again for future requests.

    The intelligent recursive servers will give the client these round robin IPs in a random order for load distribution, but it doesn't matter if they don't as pretty much all authoritive DNS servers automatically rotate/shuffle the order of the addresses in the round robin.

    I can back up both of these points with an example:

    # dig www.google.com
    
    ; <<>> DiG 9.7.3-P3-RedHat-9.7.3-8.P3.el6_2.2 <<>> www.google.com
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7774
    ;; flags: qr rd ra; QUERY: 1, ANSWER: 7, AUTHORITY: 4, ADDITIONAL: 0
    
    ;; QUESTION SECTION:
    ;www.google.com.                        IN      A
    
    ;; ANSWER SECTION:
    www.google.com.         115451  IN      CNAME   www.l.google.com.
    www.l.google.com.       77      IN      A       173.194.66.104
    www.l.google.com.       77      IN      A       173.194.66.105
    www.l.google.com.       77      IN      A       173.194.66.106
    www.l.google.com.       77      IN      A       173.194.66.147
    www.l.google.com.       77      IN      A       173.194.66.99
    www.l.google.com.       77      IN      A       173.194.66.103
    

    Google are using DNS round robin for www.google.com.

    1) They have a low TTL, backing up my first point.

    2) What happens when one of these IP addresses goes down? I would imagine with hundereds of thousands of servers (maybe millions), some of them sometimes break. If 173.194.66.147 goes down, do you really have a 1 in 6 chance of not being able to access Google until the short TTL expires?

  • miTgiBmiTgiB Member

    @NickW said: If you don't see it as a viable solution then you are incredibly misinformed.

    Go setup your no-name site with DNS Round Robin and see how RoadRunner, Comcast, Verizon ... do not honor your TTL

    Yes, they absolutely do honor it from a site like Google, just like any other top site, and I also see on a daily basis they do not honor TTL for the majority of no-name sites.

  • Somebody mentioned it before.

    Maybe using Google AppEngine is a good option.

    I mean setting up a CDN there.

    Check this out http://cdn-cloud.appspot.com/

  • NickWNickW Member

    @miTgiB said: Go setup your no-name site with DNS Round Robin and see how RoadRunner, Comcast, Verizon ... do not honor your TTL

    Yes, they absolutely do honor it from a site like Google, just like any other top site, and I also see on a daily basis they do not honor TTL for the majority of no-name sites.

    I'm slightly offended by the first part of your comment "Go setup your no-name site with DNS Round Robin". You should not make assuptions about somebody you know nothing about. No I do not operate some "big-name" website, but that is none of your business. But I'm quite happy with how my "no-name" sites are coming along, and I'm not using RR DNS at the moment anyway.

    Plus, they will honour my TTLs, because they're all at least an hour. Surely screening for large sites to honour the TTL for is going to be far more effore than just honouring all TTLs.

    DNS RR does not require a short TTL to work. Browsers are pretty damn smart these days.

  • netomxnetomx Moderator, Veteran

    By the way, if anyone uses Round-robin ... how can you propagate MySQL tables to your VPS?

  • NickWNickW Member

    @netomx said: By the way, if anyone uses Round-robin ... how can you propagate MySQL tables to your VPS?

    That is a much more complex situation. RR DNS was recommended for the OP because of simple static file downloads. Large sites doing RR DNS are running a separate database cluster anyway.

    One way to do it may be with master-master replication, but I would do some serious research and testing of what happens when one goes down before putting it into production.

  • @netomx said: By the way, if anyone uses Round-robin ... how can you propagate MySQL tables to your VPS?

    MySQL is one vps or many VPS (Master/Slave replication). All VPS access same database.

  • PADPAD Member

    You can just have all of the nodes connecting to the same remote MySQL database.. don't see why everyone seems to think its complex at all.

  • netomxnetomx Moderator, Veteran

    @ShardHost said: Master/Slave replication

    Will check that! Would it be better to connect themselves via VPN ?

  • NickWNickW Member
    edited June 2012

    @PAD said: You can just have all of the nodes connecting to the same remote MySQL database.. don't see why everyone seems to think its complex at all.

    You're introducing round robin for either load distribution or pseudo-redundancy. Connecting to a single MySQL instance then nullifies this, unless the load distribution is for bandwidth pooling.

  • PADPAD Member

    You wouldn't introduce load distribution just for MySQL, sure there are many ways you can do it and it can get complex, but so long as you have a dedicated MySQL server having all of the nodes connect to one centralized MySQL server still isn't that bad.

    Thanked by 1NickW
  • jcalebjcaleb Member

    @joshuatly could you round robin in your PHP script? e.g. have array of ip then on render of link, you can choose at random.

  • There is no point using a scripted solution. The user has stated he wants the files to be available if one server is down.

    If the server containing the script is down all of the servers will (to the end user) be down also.

  • MaouniqueMaounique Host Rep, Veteran
    edited June 2012

    Not really random... Tho, it may work, if you put a sign there: If it does not work, refresh the page.
    I was thinking more like a php script that will check in advance if it can access the file, then send the URL after doing the random thing.
    It does have a single point of failure, if the main site is down, ok, you are screwed, however, a roundrobin can deal with that issue somewhat.
    It gets too complex tho.
    So, a simple and not bad solution is to host main site with a big provider or one of the stable lebs you know from the experience to be stable, and the rest use only to balance traffic via a simple script.

    @ShardHost said: The user has stated he wants the files to be available if one server is down

    Yes, but he said the file. He wants to use this to load balance the file distribution, I dont think the main site is in discussion here.
    M

Sign In or Register to comment.