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.

Tips for Surviving DIGG AFFECT

Discussion in 'Site & Server Administration' started by cupid, Nov 5, 2006.

  1. #1
    Can someone provide me tips in terms of apache server and mysql server issues I have to look out for. How many silmultaneous connection mysql can handel and any other tips. Planning to setup one dedicated server running apache and mysql on it.
     
    cupid, Nov 5, 2006 IP
  2. frankcow

    frankcow Well-Known Member

    Messages:
    4,859
    Likes Received:
    265
    Best Answers:
    0
    Trophy Points:
    180
    #2
    I've been able to survive very well by just not having anything interesting on my site...
     
    frankcow, Nov 5, 2006 IP
    Halobitt and mad4 like this.
  3. PayItForward

    PayItForward Peon

    Messages:
    752
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    0
    #3
    1. Use a 2nd server
    You can use a tiny, lightning fast server to handle static documents & images, and pass any more complicated requests on to Apache on the same machine. This way Apache won't tie up its multi-megabyte processes serving simple streams of bytes. You can have Apache only get used, for example, when a php script needs to be executed. Good options for this are:

    TUX / "Red Hat Content Accelerator" - http://www.redhat.com/docs/manuals/tux/
    kHTTPd - http://www.fenrus.demon.nl/
    thttpd - http://www.acme.com/software/thttpd/

    2. Use a proxy cache
    A proxy cache can keep a duplicate copy of everything it gets from Apache, and serve the copy instead of bothering Apache with it. This has the benefit of also being able to cache dynamically generated pages, but it does add a bit of bloat.

    3. Use hdparm to tune your hard disk. With this utility, you can control the input/output
    controls for the standard IDE driver included in most stock Linux distributions. Most of
    these options work with the regular IDE driver, but some require the more modern
    EIDE drivers that comes in kernels later than version 2.0.10.
    If you are using a default Linux install, you could speed up Linux's access to your hard
    disk by 200%. hdparm is mostly useful for IDE hard disks, but some hdparm settings
    work with SCSI also.

    4. MaxRequestsPerChild setting determines how many requests a single child can
    handle before Apache spawns a new child. The default value is 30, but you should
    consider raising it: Apache is robust enough to handle a good load. If you use
    mod_perl, reconsider modifying this value from its default, since that module
    causes the child processes to have bloated memory pages.

    5. Serve graphics from a seperate machine, a shared hosting account or even a VPS if needed, a second dedicated server if you have the budget.
     
    PayItForward, Nov 5, 2006 IP
    JEET and agnivo007 like this.
  4. agnivo007

    agnivo007 Peon

    Messages:
    4,290
    Likes Received:
    289
    Best Answers:
    0
    Trophy Points:
    0
    #4
    good tips,PayItForward. rep for ya!
     
    agnivo007, Nov 5, 2006 IP
  5. cupid

    cupid Peon

    Messages:
    284
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks, PayItForward...

    Anything I can do on MySQL side?
     
    cupid, Nov 6, 2006 IP
  6. PayItForward

    PayItForward Peon

    Messages:
    752
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    0
    #6
    1. * MySQL is interpreted from right to left so you should put the most significant limiters as far to the right as possible.
    2. * Only select fields you need, instead of selecting * (everything).
    3. * Don't put things that changes very rarely in the database, instead put it in a global array in some include file.
    4. * Use indexes on the columns in the WHERE clause and on the columns you want to ORDER BY.
    5. * Indexes are great if you search the table alot, but it slows down insertion.
    6. * Use the EXPLAIN command to analyze your indexes.
    7. * If you only want one line as a result from the database you should always use LIMIT 1. This way mysql stops searching when it finds the first line instead of continuing through the whole database, only to find that there weren't any more lines that matched the query.
    8. * If you use $line = mysql_fetch_array($result) you'll get two ways of accessing the columns, $line[0] and $line['columnname']. If you only use the $line['columnname'] you should use $line = mysql_fetch_assoc($result) instead, then there will not be any $line[int index] array.
    9. * Sometimes mysql_free_result() end up wasting more memory than it saves. Check the difference with memory_get_usage().
    10. * Don't ask the database for the same stuff over and over again, save the result.
    11. * Use NOT NULL as default value as much as you can, it speeds up execution and saves one bit.
    12. * Use datatypes that fits your data, not too large. For example, INT can hold values up to 4294967295 unsigned, which is often unnecessarily big. Use MEDIUMINT or SMALLINT where applicable.
    13. * Make use of the default values, only insert values that differs from the default values to speed up the insertion.
     
    PayItForward, Nov 6, 2006 IP
  7. forkqueue

    forkqueue Guest

    Messages:
    401
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #7
    The best advice for tuning on the cheap is simply to make the page that's Dugg static. If you *must* have MySQL on the landing page, make sure you've got as few queries as possible.

    In terms of hardware, if you're doing a lot of disc I/O go for SCSI (I'd never use IDE/SATA for a serious site), but make sure you have as much RAM as possible, so that you're caching as much as you can.
     
    forkqueue, Nov 7, 2006 IP
    JEET and PayItForward like this.
  8. bochgoch

    bochgoch Peon

    Messages:
    1,918
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #8
    ...good advice...even with a dynamic database driven site think about pregenerating landing and high volume pages from the database using cron or similar, you can always leave less visited pages as dynamic.
     
    bochgoch, Nov 7, 2006 IP
  9. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Don't use Wordpress is my tip. Or if you do at least make sure you are caching the pages.

    WP uses 17 queries to load a simple blog page. My blog software uses 3.
     
    mad4, Nov 7, 2006 IP
    PayItForward and JEET like this.
  10. JEET

    JEET Notable Member

    Messages:
    3,825
    Likes Received:
    502
    Best Answers:
    19
    Trophy Points:
    265
    #10
    WOW! Very useful tips in this thread.
    Added a green to all who suggested useful stuff.
    I would like to add that never put a query in a loop, especially if the query is based on user input.
    Hold the result in an array, and get values from there.
    Bye :)
     
    JEET, Nov 7, 2006 IP
  11. PayItForward

    PayItForward Peon

    Messages:
    752
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    0
    #11
    This thread is packed full of good information! :)
     
    PayItForward, Nov 7, 2006 IP