Optimizing Performance Notes

  • Digg this article
  • Sphinn this article
  • Stumble this article
  • Facebook
  • del.icio.us
  • LinkedIn
  • Twit this article
Posted by John
on Sunday, 16 November 2008

GoodWood Revivial

Two weeks ago I visited a conference on website performance at the SUN UK offices, quite an eye opener; here's a bit of what I learnt.

Sharding

When you're site's performance is lacking the usual idea is to upgrade the hardware and buy bigger and more powerful servers, better hardware, etc. However another approach is to use a technique called Sharding.

Basically you analyze the users pulling the biggest load off your database and separate them into shards so rather than User A hitting the main server, they hit a shard of that data server, same goes with User B; in essence you separate the people requesting the most out to individual boxes rather than the main one. Employ an army of cheap Linux boxes to create this modified farm and balance the data requests strategically out so they're evenly hit.

It's a federated model, groups of users are stored together in boxes of shards.

So if one box goes down, the others still operate. The work is shared out among your virtual server farm, you get more write performance and you reduce the bottleneck, but you also work out where you're main draw is an share that out so one guy isn't left doing all the work.

There are some disadvantages in going this way but it's a good start in solving a potential problem as your site grows.

Load Balancing

You can also employ Linux's Native Kernel Load Balancer to help (Google this), plus there are two packages available for the O/S to help in this area:

Clustering

Clustering may also be a good thing to look at, which is like sharding but simpler in that you build a farm of servers and load balance the users across them. So the first user hits box 1, then the next user hits box 2, and so on; once each box has a user you go back to box 1 and add a user, and so on balancing the load out.

CDN

Content Delivery Network, if you've got enough money in the budget then you might be able to employ a company like Akamai or BitGravity to help you out with serving your videos and media to the customers rather than your boxes taking the brunt of this less complex work.

The last one is a new service Amazon are offering, currently in beta; but be warned none of these services are cheap if you've got a big hit count.

General Stuff

You could also try to make friends with your hoster, who knows you might get along well and they might even want to take an interest in what your doing; helping out along the way with extra bandwidth or advice.

Pick your quick-wins and operate on those first, if you can get the performance up with a couple of hours focusing on the rough edges of your site; that'll give you breathing room to focus on the core before things get difficult.

Latency kills FaceBook apps, the majority of their users are US-based and thus it helps having a box in their country so the network doesn't have to trek across the oceans to grab your data. Think of all those Doom DeathMatch's you played as a kid; when the server was closer to home it really helped in getting that high score.

Master-Slave relationships are simple to implement and maintain, Multi-Master is a headache.

SATA drives are bad for random-writes, SAS (Serial SCSI) discs are much more suited to this; grab some 2.5" 15k ones.

Make sure you've set an Expires header to your served data, this makes it cache-able reducing the time it takes to grab your HTML, gif, jpg files from your box. If your style-sheets don't change much you can use this to tell your client's browsers so they know not to grab a new copy each time they do a request.

Also if you've got abundant amounts of memory consider employing RAM-Disks to keep the most used apps in memory rather than constantly paging to disk.

Tools

Replacing your MacBook Hard Drive + Leopard

  • Digg this article
  • Sphinn this article
  • Stumble this article
  • Facebook
  • del.icio.us
  • LinkedIn
  • Twit this article
Posted by John
on Friday, 14 December 2007

The Illusionist

Nice Mr Postman dropped by two parcels today, one a massive 250gb WD Scorpio drive and the other MAC OSX Leopard.

Perfect end to a not-so-nice week, caught a virus; ended up feeling like an extra from Outbreak; the more you don't know the better ;-)

Anyway,

Choosing a Hard Drive ?

Obvious question, what do you need?

Specs

Well the MacBook drive is an SATA 2.5" drive, so make sure it's:

  • SATA = Serial ATA
  • 2.5" = in height
  • Max Size you'll get = 250 GB

Where From ?

You can buy these from any online computer store, I used OverClockers.co.uk but any decent retailer or Amazon should have some.

Go with the courier delivery as it's an extra protection and in the event of failure, you've got some fallback ground. Worth the £8 more.

Brand ?

Next off what brand?

Well I've been always partial to Western Digital but most any brand will do, I haven't had much luck with Seagate in the past but they're all pretty much the same.

The standard drive is by Toshiba so that maybe good, just make sure you don't compromise; you only want to be doing this once.

Replacing the MacBook Hard Drive

Replacing the hard-drive on my MacBook wasn't that tough.

  • You will need a TORX screwdriver (T-8 I think), nip down to your local car mechanic and they'll have one.
  • Next flip over you MacBook and use a coin to turn the screw and release & remove the battery.
  • Now touch the metal base inside the macbook to discharge any static electricity (do this every now and then to be sure).
  • Next unscrew the three protection screws holding the L plate in.
  • Carefully remove the L plate.
  • Now you have access to the two memory bays and the hard drive bay (located under the battery screw).
  • You'll see a white tab holding you hard-drive in, pull it gently to release and slide out your macbook's drive.

Be Careful to only touch the sides of the drive, not any circuitry. silicon and human moisture do not mix!

  • With the drive now out, use the TORX screwdriver to remove the 4 retaining screws holding the drive chassis in place.
  • Now remove the drive, replacing it with your new drive, screw back in the retaining screws.
  • NOTE: Don't screw them in too hard either you will ruin the thread, just enough to be a good fit.
  • Slide the drive back in with the connectors pointing towards the battery screw.
  • Should go in snugly, don't need to force it.
  • Now put back the L plate
  • Screw back in the 3 retaining screws of the L plate (might need to use a mini-screwdriver to push in the little anti-static sponges).
  • Put your battery back in and use the coin the lock it in place.

All Done...

  • Now the scary part, turn it on.
  • You should see a Folder icon, this tells you there isn't an O/S present for it to start.
  • Slide in the Leopard DVD and wait for it to boot.
  • The disk may take a few minutes to realise what it is but after you should be ok.
  • Enjoy your handiwork!

ABOVE ALL AND UNDER NO CIRCUMSTANCES RUSH THIS!

It's a good machine and deserves a little bit of care and attention when replacing it's innards, rushing around and bodging the job isn't nice.

Enjoying Leopard

God if only Vista was as easy to install, stick dvd in, wait, yes i'm english, here's my wifi, yep install, done...

The effects and presence is just startling, it's like Tiger only really well polished!

I also seem to remember Apple mentioning Leopard has SUN 11's VFS (Versioned File System), so self-healing files is in-built; no more corrupted files ever!

Auto Preview folders definite plus and Screens.

It just looks and responds so much better.

Well done Apple, all software should be this easy to setup, I'm not a fanboy; I just believe in making the developers life a little easier.

Plus it comes with Ruby 1.8.6 out of the box!

Cool.