Find the answer to your Linux question:
Results 1 to 8 of 8
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Question From single server to cluster


    Our single server running a LAMP application at our coloc is getting slower, and I was thinking of putting X Apache servers as front-end, all connecting to a data server for MySQL + JPG. I've never done this before, and have a couple of questions:

    1. Should I use NFS to connect the Apache servers to the MySQL server, or should I look at something else for higher performance (FireWire, etc.)?

    2. In case we need to have more than one data server, what would you recommend for load balancing + data synchronization?

    Thank you.

  2. #2
    Linux Engineer jledhead's Avatar
    Join Date
    Oct 2004
    North Carolina
    you could do high availability and load balancing using linux virtual server for the load balancing and heartbeat for the failover, and drbd for the mirrored file system

    If what apache was doing was making money, I would want it up and responsive and much as possible. the above software would do that. I haven't used drbd but have used the rest and they work like a champ and if you post back I will help where I can.

    here are some various links
    DRBD: Linux HA
    HomePage: Linux HA
    The Linux Virtual Server Project - Linux Server Cluster for Load Balancing
    and help with config and setup
    Ultra Monkey:

  3. #3
    Thanks for the links. Before digging too deep, I should probably try the major diagnostic tools to make sure where in the stack the application is slow. Do you know of a good article that teaches newbies how to go through this (eg. ps, top, PHP xdebug, MySQL Explain, etc.)?

  4. $spacer_open
  5. #4
    Just Joined!
    Join Date
    Mar 2008
    Things I would do first....

    Make sure I have a dual or quad cpu board...and try to get some nice intel harpertowns in there.
    Max out my ram.

    Make sure my hardrive controller cards or raid thingees are set up more to deliver than accept (in other words, a webserver sends more data than receives, so more open on one side of that means better drive access speed)

    Software raid better than hardware raid for webserver, faster.

    Raid 1 mirrors better than the other raid types, for a webserver.

    Make sure other programs not needed are not starting (like cups and junk like that)

    Are my hard drives enterprise drives (fast and made to run for long times?)

    Is my NIC card set right, or is it set to a lower number than it should be?

    I would double check my dns/hosts/mail settings to make sure there are no resolve problems..this also incudes any outside dns pointing like my registrars or thrid party dns I may be using.

    Do I sned a ton of mail? Perhaps a second server used for mail would be good instead of balancing.

    When was the last time I rebooted? Have i checked my logs to see any weird errors?

    Is my mail configurations NOT set to relay mail? If not I may being used as one.

    What is my colo interent connection speed like? Is my colo provider not so good? If they give you a bad connection, that is the issue.

    Do I connect directly to the internet or do I go through other equipment first (router, firewall, etc) and am I sharing that in a rack? That would be a huge issue and may be your problem.
    A stand alone webserver, on linux, does not need a router or firewall (has one already with linux) to connect to internet. Also that switch/hub thing can take out your speed too.

    Am I using lots of free OOP software for my main php applications? These apps are a huge overhead, take way too many pages to do simple things, and on a fast site can bog you down pronto....regardless of mysql, jpegs, or mail. RAM can help as can more cpus in this case.
    Prgramming for heavy use means streamlining user processes through your site. A lot of programs exaggerate the steps needed by a user to get something done. Streamlining can take 50% of your load and make it disappear. Add to that a lot of uneeded scripting like javascript and your user looks like he is using a slow site (the javascript is more on the users side, but with your site doing too much and his computer having to do more, it really gives a 'wait for page to load' experience).

    In my experience, if it is just a webserver, one computer should be able to do it unless you are a superhuge company with 10s of millions of 'real visotirs' and not 'hits' or webalizer visitors. Good ram, good cpus (not just one), good fast drives with lots of room, software raid, good speed on HD controller to server information, no raid hardware bottleneck, clearing out useless programs, no mail relay, mail programs streamlined for off times and also not 'all at once' sendings will do you fine for a long time.

    Video and other media like pics can slow you down too. Pics uploaded should be imagemagicked or gd'd upon upload to condense file size...not done everytime a pic is viewed. Videos should be watched for huge filesizes and adapted before being uploaded.

    Look for loops in your ynamic php/mysql applications that can be causing a this by testing on your home server where no one is surfing to and checking out any heavy activity.
    Sometimes a poorly designed myql command can cause some issues. Check mysql for proceses running. Do you have one running for 3 months? Could be one of your culprits.

    Honestly, it sounds like you just need to upgrade. Better ram and cpus can be amazing.

    Also, is your swap partition big enough?

    that is it for my advice. Going to load balancing is a big things, and if you are doing it because of any issues I listed above, then you are not solving your problem, only pushing it off for another day when those uneeded servers finally buckle from the issue.

    Good luck and happy head scratching....

  6. #5
    Thanks a bunch for the help

    Here's my summary, with a couple of included questions:

    1. Get dual/quad CPU board (eg. Intel Harpertowns) + lotta RAM
    2. Disk controller (either SCSI or RAID) should favor read over write, as web servers perform more outputs to clients than inputs; Enterprise-grade disks
    3. Sofware RAID instead or HW RAID (why faster?)
    4. RAID1 (why not RAID0?)
    5. Uninstall any unneeded program (CUPS, etc.)
    6. Good NIC, set up right
    7. Check DNS/mail settings to avoid resolve and other configuration problems (relaying, etc.)
    8. If sending lots of mail, consider a dedicated server
    9. Check system/application logs for possible hints
    10. Check total bandwidth at colo (switch, router, etc.)
    11. In PHP, don't include unnecessarily heavy add-on's
    12. Resize uploaded pictures when writing to disk, so won't need to do this with every hit
    13. Profile PHP + MySQL; Check that MySQL doesn't have run-away processes
    14. Check if bigger swap partition
    15. Consider load balancing only after checking the above

  7. #6
    Linux Engineer jledhead's Avatar
    Join Date
    Oct 2004
    North Carolina
    Quote Originally Posted by littlebigman View Post
    3. Sofware RAID instead or HW RAID (why faster?)
    there is a reason software raid is called fake raid. you have the overhead of software running the raid so it is slower

    4. RAID1 (why not RAID0?)
    because you care about your data. lets say you have 2 drives on raid 0 and 1 drive fails, guess what, all the data across both drives could now be junk. the reason is with raid 0 it treats both disks as 1, so if you save a file to the disk, it alternates saving byte by byte to each disk. obviously this is faster but not good if you care about your data.

  8. #7
    Just Joined!
    Join Date
    Mar 2008
    Most raid setups are designed for great access speeds and the whole two way of large corporations. On a webserver you are mainly about sending data and if you google it you will actually see how using other raids instead of a mirror cna slow you down on a webserver.

    Raid 1 mirros the disks so if one fails the other works and all info is there. Throw in a hot spare, a thrid drive that takes over if one fails, and you are really cooking.

    Hardware raid versus software raid has many hooks and crooks. Yoiu can google to read about it. For starters, if your hardware raid fails you are SOL until you buy the same one and replace it. You are dead. Done. Software raid will mean one less thing that can break down. Fixing any issues with software raid is easy. It is also easier to manipulate the partitions than having to go through a hardware configuration.

    Add to that the need for extra battery protection for your raid card...and the extreme percentage chance of corruption over software raid and for your webserver you should go with software raid.

    You might want to google before you decide, but read on it. Also, since you are sending mostly and not receiving data, you will find both online and in practice that software raid is much faster, especially with large loads.

    THis of course is about webservers and not servers used for business networking. Different animal. Google around and check out software versus a few pages, not just one.

    THe cost savings is dramatic. The headache savings is priceless. The difference in potential downtime is humongous.

    When reading about raids, keep searching for the seek times and data transfer rates. As you read all this you will see how the different raids are attuned to different setups.

    A busness server with 1000 clients accessing it, and webserving, and those clients sending and receiving data along with sending web stuff, is a hugely intense thing and more suited for hardware raid and a different raid set up other than mirror.
    A webserver alone derives much better speeed and performance not using a raid card, using software raid instead. Raid 1 is not about speed, it is more about you keeping your server up during a hardware problem.

    That transfer rate that you see, lets say 3gb, is usually 'both ways' and a lot of hardware will separate that into 1.5 one way and 1/5 the other. Add the raid hardware doing more of that, and adding another middle man to it, and you can get some slow speeds if you are trying to do 3gb one way and .5 gb the other

    In your reading you will see how memory, mem cache, and cpu work with hardware raid versus software raid, especially in the difference between systems that have huge data coming and going versus mostly just data going (webserver).

    In most cases, on small servers, neither one of these is really an issue and no raid setup or use will really matter. This is why software raid wins since you save alot of money, lower the number of hardware items that can break, lower corruption issues, and have an easier repair if something does go wrong.

    Now, if you are a huge server with 100 million people coming to you...well, time for that whole load balance/cluster/etc that point you are rich and hire someone to worry about that sh#t

    edit: I would add that software raid allows for non identical drives being used.
    The drives can also be taken to any linux system and accessed without having to buy a raid card.
    You can play with the partitions across many drives for storage and stuff, gotta read online about that, nuff to say a lot of options are available over hardware raid.

    raid 1 is not a back up, it is a system 'stay up' kind of thing. You should get another drive to back it all up on as a precaution. Or, if you have a 3rd drive as a hot spare you could just unmount or pull out drive 2 and let drive 3 start syncing...that means that drive 2 is a complete backup of everything up til the time you pulled it I guess you could write a script for this....

    Here is one nie articel that covers a lot of the of many
    LinuxPlanet - Tutorials - Using RAID in Linux - Hardware vs. Software RAID

    Edit2: Raid1 is only raid you can boot from. So if you mirror it all correctly and grub it right, all your drives are bootable no matter which one fails. And addign swap partiton will also allow that to function properly should you experience mem problems down the road.... I just love raid 1

  9. #8
    Thanks guys. I'll look into software RAID1, then. We're also checking out moving the MySQL + JPG's onto a NAS and share data among multiple Apache servers.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts