Crash Course in Performance Tuning

One of my buddies runs a very popular sports blog which was hitting a performance bottleneck and was looking around for a dedicated host.  He was unclear on how all the hardware specs helped him scale.  I sent him this email hoping to give him some insight.  I figured it was a good crash course on performance tuning concepts and might be useful to some other people out there.

A quick crash course in performance tuning.  When running a high workload you’re eventually going to hit a “bottleneck”.  This is some limiting factor which doesn’t allow you to run any faster.  Think of it as the speed limit on a highway.  You can fix one bottleneck by giving more resources to it and causing the site to run faster until the next bottleneck is hit.  You then address that bottleneck.  You keep going until there is no clear bottleneck out there.

There are 4 common bottlenecks.  They are CPU, memory, network and disk speed.

Let’s go in reverse order:

Disk speed: This is by far the biggest issue for most websites.  However, it is easily solved by taking disks out of the equation and moving commonly used items  to the very fast memory.  Moving items to memory can be done by adding Squid for images, using Memcached instead of the database, or a larger buffer pool on MySQL/InnoDB.

Network: There are two ideas in network.  The hardware and the bandwidth.  And the term “bandwidth” is misleading.  Bandwidth is just how _much_ data you are allowed to transfer over the course of a month, it is not a statement about how _fast_ the data transfer.  The speed of a network transfer is in the hardware.

Memory: For every person that comes to the website they will use a certain amount of memory to be able to send them a webpage.  That memory is being taken up for as long as the website is still sending them the webpage (ie a connection being open).  However, if the website isn’t sending the pages fast enough, then that memory is used longer, and eventually you’ll run out.  Additionally, memory is used for caching to alleviate the disk bottleneck.

CPU: The goal of all performance tuning is to make CPU the bottleneck. The reason being is that you can throw more hardware at the problem and it will fix things.  This is not typically the case in all the above bottlenecks.

Dedicated vs. Virtual hosting:  Their are _major_ advantages to not virtualizing.  When you virtualize something, it does makes things easier to manage, however it slows the hardware down a lot.  So the hardware that you have can not run nearly as fast.  Additionally, unless it’s “dedicated-virtual”  there are other websites on the same hardware.  These other websites will compete for hardware resources and will not allow websites to run as fast.  By having a server “dedicated” it makes sure that the hardware is “dedicated” to your website only.

Nerd Stuff

Leave a Comment

Your comment

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.