Monday, February 13

Saving your PC, one Hard drive at a time

So the l33t geeks at your institution have set up a kick ass file sharing system. There is like two terrabytes of content just waiting to copied, compressed and digested. But for some weird reason every time you open up your "media grabber" your PC slows to a crawl and your hard drive makes a grinding noise.
Welcome to what I and a lot of other folks like to call a "Network". Due to the higher bandwidth of this "network" in comparison to the internet, p2p pushes your PC's hard drive read speeds to the limits, to understand this better lets look at some figures.

The average sustained HDD read speed is about 30-40MB/s(Megabytes per second) in ideal conditions,
The theoretical maximum of a 10/100 network is about 12 MB/s, but in reality it's more like 10 MB/s.
Now these HDD read speeds are testing your drive doing one thing at a time, so either reading or writing, Hard disk are studious devices.
However with P2P you get to do both, at the same time. And if you got more than a few people downloading off you you can see where the numbers start to look bad. Drives just want you to have fun, so they bust their chops to get the data out as fast as possible, mamma Maxtor always told them to do their best, if you don't Seagate will eat you! Sure some NCQ(Native command queuing) might be helpful, but to those of us without RAID 5 setups or Nforce 4 chipsets those are wishful thoughts, so how do you stop this freak of tech.
What I'm going to do is limit the maximum speed that programs can request data over the network, meaning that my hard disk only needs to go as fast as the slowest component which is the artificial bottleneck that I'm going to create. So instead of 5 MB/s upload speeds (which is ridiculously fast) we have 200 KB/s which is a lot more heathly for your 7200 RPM rotating patters.
Sadly I haven't come across a open source solution (incase you didn't know we like Open source stuff), but I did find a program that does the job. It's called Netlimiter. It allows you to control the about of network bandwidth allowed to each program, on each network interface. It's got a nice easy to use interface, and is extremely stable. Plus it's completely transparent to the other programs on your PC( oh yeah this is PC only, so as usual Mac and nix users will have to look else where).
.
All you have to do is select what program you want to limit and input the numbers in the respective boxes. Up rate is the one you want to use to stop the effect we discussed happening. To get a decent rate use this simple formula,

ideal uprate x no. Of maximum users = total up bandwidth

So if I want my fellow sharers to have 100KB/s up and I have 4 slots open for uploads, then my total bandwidth is 400KB/s. In reality I keep mine at exactly 1 Mbit and have 5 slots open. So people get 200 KB/s (minimum) from me which is on par with a 2 Megabit broadband connection.
Well I hope this hack was successful, and helped you alleviate boredom for a few more minutes. Till the next Higher Hack, I bid you a farewell.