1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Hosting on multiple servers..

Discussion in 'Web Hosting' started by ozegreatdeals, Aug 26, 2005.

  1. #1
    Hi,
    I have seen some sites claiming that they have multiple servers running their sites in an effort to improve speed and drain on processors..

    My question is, if you run a mysql database how do you run multiple servers and have the data available on all of them?

    Drew.
     
    ozegreatdeals, Aug 26, 2005 IP
  2. tflight

    tflight Peon

    Messages:
    617
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    0
    #2
    There are a few ways to go about this depending on the desired architecture. One way would be to have the HTTP server on one machine, mail server on another machine, MySQL on a third machine, etc. You could also setup a MySQL cluster, implement a load balancing scheme between multiple MySQL servers, etc.

    The way your question is leading though you could have each of scripts running on the HTTP server(s) setup to point to a separate MySQL server.
     
    tflight, Aug 26, 2005 IP
  3. ozegreatdeals

    ozegreatdeals Peon

    Messages:
    326
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yeah I was wondering sites like studiotraffic.com to be exact state they have 8 servers powering them... I would not mind to have a second server to run my site which is also a autosurf site or my ptc site. But not sure how to go about setting it up so that all "sites" have access to the database.

    Drew.
     
    ozegreatdeals, Aug 26, 2005 IP
  4. tflight

    tflight Peon

    Messages:
    617
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    0
    #4
    If you currently have the load to warrant a second server then I'd setup HTTP on one server and MySQL on the second. Then the MySQL connection scripts on each site point to the MySQL server.
     
    tflight, Aug 27, 2005 IP
  5. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #5
    The base of such configuration is multiple web server machines configured to connect to the same database machine; then you need to load-balance them. That is, to the outside world, it will appear that you have only one web server.

    DNS can provide a simplified form of load balancing. That is, you can configure your DNS server so that one domain name has multiple IP addresses associated with it. Every time the DNS server serves a DNS request, it will pick the next IP address, thus balancing the load on your servers.

    If you have some money to spend, you can use a dedicated load balancer. A load balancer has one IP address visible on the outside and multiple machines connected to it on the inside. All incoming traffic is received on that single IP address and then forwarded to the appropriate machine on the inside using various techniques (e.g. to balance the number of connections per machine, transfer amounts, etc).

    So, your configuration would be like this:

    IDC router (public IP address)
       (public IP address) your firewall (192.168.1.1)  
       (192.168.1.10) LB (192.168.1.11)  
            (192.168.1.50) web server 1  
            (192.168.1.51) web server 2  
       (192.168.1.100) database
    Code (markup):
    That is, your public IP address is mapped at the firewall level to 192.168.1.10 - LB's IP address. Each of the load-balanced servers (50 and 51) connects to the shared database machine.

    J.D.
     
    J.D., Aug 27, 2005 IP
  6. blinxdk

    blinxdk Peon

    Messages:
    660
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I use LVS (Linux Virtual Server - http://www.linuxvirtualserver.org/).

    Currently the LVS distributes traffic to 5-6 webservers on a least connection basis. The webservers connect to a clustered mysql backend for content.

    Works fine, I have been running these kind of setups for years, but it does require a bit of basic linux and networking knowledge.
     
    blinxdk, Aug 27, 2005 IP
  7. ozegreatdeals

    ozegreatdeals Peon

    Messages:
    326
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #7
    thanks everyone for your help and suggestions. I currently know very lttle about these sorts of things but will definetly keep it in mind, at present both sites are running ok but may need to use one of the above suggestions for the autosurf as it uses the most bandwidth, and occassionally locks users out because of too many connections to the mysql server.

    Drew.
     
    ozegreatdeals, Aug 28, 2005 IP
  8. blinxdk

    blinxdk Peon

    Messages:
    660
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #8
    If your mysql server can handle it, then it is just a simple change in the configuration to change the max allowed connections. Watch how high you set it though, it's there for a reason and you don't want your server to die because of too high load.
     
    blinxdk, Aug 28, 2005 IP
  9. ozegreatdeals

    ozegreatdeals Peon

    Messages:
    326
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Thanks... Yeah looked at that but one of my sites has been thru like 3 hosts already and that is just with the standard settings in mysql settings as apparently it uses heaps of processing power managed to crash the original host..

    Drew.
     
    ozegreatdeals, Aug 28, 2005 IP
  10. blinxdk

    blinxdk Peon

    Messages:
    660
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #10
    MySQL tuning and trimming can have quite large effects, especially the buffer memory settings are quite important. The same is true for your actual DB and query design, using indexes is really important for good performance.

    If you have shell access to the server, you can try running mysqladmin extended-status, things to look for is large number of created tmp disk tables, and a Handler_read_rnd_next number that is much larger than Handler_read_rnd a sign that you might need to improve your index.

    We usually average +1800 queries/sec and it doesn't take much misconfiguration to bring it all to it's knees.
     
    blinxdk, Aug 28, 2005 IP
    Willy likes this.
  11. Willy

    Willy Peon

    Messages:
    281
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    0
    #11
    In addition to the above good advice by J.D. & blinxdk, one thing to look at is increasing the number of file handles (i.e. the maximum number of files that can be open at any one time).

    This has bitten me sometimes when setting up high-volume sites on Linux servers, as every MySQL temporary database eats up a file handle or two. Since there already is a scarcity of file handles available, as the web server will grab one for each separate virtual host's log file and so forth, during high load MySQL will fail simply due the kernel running out of file handles (which, if you really do have to crush and burn, is a fairly useless reason). Worst of all, MySQL will fail with a very unhelpful error number so it can take some figuring out to find the actual cause.

    You can check how many file handles your server can currently handle by issuing the command 'ulimit -a'. For high-volume deployments the default number will be way too low. Check 'man ulimit' on how to increase the number.

    Also, if you're using a Debian system at least, it will ship with several example configurations for higher-volume deployments. You can find the files my-medium.cnf, my-large.cnf, my-huge.cnf and my-innodb-heavy-4G.cnf in the directory /usr/share/doc/mysql-server-4.1/examples/. Easy to adapt the relevant settings from them to fit your particular situation.
     
    Willy, Aug 29, 2005 IP