#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2008
    Posts
    46
    Rep Power
    22

    Setting up simple load balancing


    I'm putting up a beta site on a few VPS servers. Server 1 is for log in. When a user hits Server 1, a need to have a simple program to look at things like the CPU utilization, memory usage, and bandwidth utilization at that point on Server 2 and Server 3 and send the user to either Server 2 or Server 3 depending on which server has lower usage. I will have full root / administrative access to the servers.

    > Does anyone have simple PHP programs similar to this that I could modify?
    > Where is the best place for this to sit on Server 1?

    Thanks for any suggestions!
  2. #2
  3. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,846
    Rep Power
    6351
    Why not use an actual load balancer software? PHP is the wrong language for this.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2008
    Posts
    46
    Rep Power
    22
    I'm trying to keep costs down while I prove out the concept. If the load balancing software costs and implementation costs (since I'll need to pay someone to do this) aren't expensive, I would consider it.

    If anyone has any suggestions on specific open-source or low-cost software, please let me know.

    Thanks!
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,343
    Rep Power
    594
    I have no first hand knowledge but Source Forge's Distributor might do what you want.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  8. #5
  9. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    If you're just writing a script to decide whether or not to redirect the user to www2.site.com or www3.site.com PHP will work OK. If you're trying to balance the load transparently (ie: both servers at the same address), then don't use PHP for this.

    For the first case, you might want to set up a cron job on servers 2 and 3 that runs every minute and transmits resource usage details to server 1. Server 1 can then use that information to determine which server to send new traffic to.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2008
    Posts
    46
    Rep Power
    22
    E-Oreo - If I am (a) doing a re-direct from Server 1 to Server 2 or 3, or (b) having users log in on Server 1 and then send them to Server 2 or 3, PHP would work. Is that right?

    All -

    As I've researched a bit further, it looks like it could be done pretty easily in apache using mod_proxy_balancer (https://blogs.oracle.com/oswald/entry/easy_http_load_balancing_with), although this doesn't account for actual load on the servers; it just gives assignments based on counters. Have others used this method with success?

    Also, I did see some options looking at Distriobutor, balance and pen.
  12. #7
  13. Known to taste like chicken
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    In front of my computer
    Posts
    399
    Rep Power
    311
    you might be able to use haproxy also. Can't remember if it assesses system load on the 'backend' servers, or if it just does a basic layer 7 check off the top of my head though.
    "Take thy beak from out my heart, and take thy form from off my door" - Homer J Simpson / Edgar Allan Poe

    Looking for a project Idea?

IMN logo majestic logo threadwatch logo seochat tools logo