loadbalance webservers (linux/apache)

Discussion in 'OT Technology' started by Mirlyn, May 14, 2004.

  1. Mirlyn

    Mirlyn Guest

    I'd like to do multiple webservers. Currently I have one and would like to add one or two more to lessen downtime chances. I'm finding conflicting stories online on how to do it. How do sessions work with multiple servers? Do I need to share the session files across the webservers, or does the client pick a server and always use that server?

    I'd like to load balance websites that have shopping carts, as well as groupware-type (email, office tools, etc) sites. Any ideas/experience/input?

    Thanks!
     
  2. Ximian

    Ximian New Member

    Joined:
    Mar 20, 2004
    Messages:
    1,860
    Likes Received:
    0
    Location:
    DCA
    Load balanced servers typically have one server that handles one customer and only that server. (with these kind of setups)

    There are lots of easy ways for doing this, like a round robin DNS or certain free GNU software that I don't recall the name of so look on Google.

    The biggest problem you will encounter is syncing data between servers because if the customer saves something to one cart, closes the session, comes back to the site to look at his cart, but there is a 1 to n chance that he'll actually be on the server that has his cart saved, so that would be a problem. You could rsync the data or just put it all on a fast SAN. It gets complicated if you have SQL databases and you try to load balance those.

    If you can get away with it, just upgrade the most used system and move a certain service to a least used system to ease the load. It'll save you lots of trouble.
     
  3. Mirlyn

    Mirlyn Guest

    Is there a way to specify the session locations (instead of the default /tmp), and use NFS to share these? I don't want to NFS mount a /tmp for obvious reasons. I wonder if apache can match another apache's session by just looking at the file. I wouldn't think so, as I could see a security risk there. Maybe not.

    SQL-based sites shouldn't be too hard, as I already have the databases on another system behind the webserver.

    I looked into round-robin DNS, but the sessions are what confused me (just like you said, 1 in n chance of regaining the session). I thought of something like Linux Virtual Server, but that requires multiple servers on a private network and use something like NAT to proxy everything into one virutal address, which I'm not fond of. Even then, you'd still run into the temp session files problem, no?

    Thanks!
     
  4. Ximian

    Ximian New Member

    Joined:
    Mar 20, 2004
    Messages:
    1,860
    Likes Received:
    0
    Location:
    DCA
    You can sync those temp session files between servers every certain period of time, like 5 minutes. Just schedule rsync and transfer it. The NFS mount works too but all of this sharing and transfering files is going to be quite a performance hit unless you're using a very low latency/high bandwidth link between the web servers.

    Like I said eariler, this gets to be complicated and quite a headache. You should just reassign roles for the different servers rather than load balance.

    1 server is web server, another is mail server and another is for other sites.
     
  5. SLED

    SLED build an idiot proof device and someone else will

    Joined:
    Sep 20, 2001
    Messages:
    28,118
    Likes Received:
    0
    Location:
    AZ, like a bauce!
    why so much session development? For this very reason i usually set a cookie on the client, and store the session information in the database. If you had a smaller dependancy on the session info, then you might not be in this mess because the web server would essencially just be a stateless organization of data. But i'm sure at this point you really don't want to re-develop your site either ;)
     
  6. Mirlyn

    Mirlyn Guest

    Good idea, but its out of my hands. I'm a webhost, not a webdesigner. ;)
     
  7. Astro

    Astro Code Monkey

    Joined:
    Mar 18, 2000
    Messages:
    2,047
    Likes Received:
    0
    Location:
    Cleveland Ohio
    As a web host, I think all you'll be able to do is just work to balance the load on the various servers by moving various sites around (example: put 1 heavy and 1 light site on one box, and 1 heavy and 1 light site on another box - versus 2 heavy on the 1 and 2 light on the other). To properly load balance, the web site would need to be designed to handle the balance that goes on (session look up in the central DB versus relying on the session files stored on disk).
     

Share This Page