Wednesday, August 26, 2009

Virtual Centos Guests

By default, a redhat/centos/fedora machine uses 1000 hz timers. This is good to maintain response to the user in a GUI, but not really needed in a headless environment. In a virtualised environment this configuration can make cpu usage on the host machine unnecessarily high, just in order to keep track of the time.

Previous getting around this problem required recompiling the kernel, but now there's an easier option. Just add divider=10 to the kernel parameters. Or if you prefer not to stress about whether or not you're putting the kernel parameters in the right conf file, just run this command as root.

grubby --update-kernel=ALL --args="divider=10"

Monday, August 17, 2009

Display Server Date Dilemma

Had this case recently where the client wanted to display their local time on the banner of their webpage. First I didn't think much of it, just required a single line of php to print out the server time (server is set to the same timezone as the client).

The server though is a VPS and the site is complex enough and busy engough to be under a bit of load, so we make use of Drupal's page caching, e-accellerator and also memcache. With that trifector running (and 1GB of RAM) the VPS handles things quite smoothly.

Displaying the time though threw a spanner in the works. Unfortunately, time continues to change, which means that it doesn't like being cached. If we're displaying the time accuracy down to the minute then Drupal's page cache would need to be refreshed every 60 seconds. Drupal's cron is set to run once an hour at the moment and considering that it does a few other tasks like checking for module updates and indexing, I don't think running the cron every minute would help us reduce load.

So I started looking for a few other options and came up with the following ideas based on moving the function to the client's browser to process:

1. Javascript could display the date using the appropriate offset and the client's clock. This relies on the client having the time (and location) set correctly on their own machine.

2. Javascript could use ajax to get a non-cached version of the date, either from our server or a separate time server. This would be accurate but would double the number of requests/responses needed.

3. Javascript could use the page response header timestamp to display the server time. I looked into this one and found that there is indeed a fileCreatedDate header, but it's not accessible to javascript in all browsers.

So at the moment, option 1 seems like the best solution to this dilemma. I'm not happy with it though, I don't like relying on the general public to have their computers configured correctly.

If anyone else has any other creative solutions to this one, I'd love to hear them.

Monday, August 10, 2009

Why do we need a 4 lane highway?

I just watched Will Hodgman's youtube video on upgrading the Midlands Highway to 4 lanes (http://www.youtube.com/user/HodgmanWill?gl=AU&hl=en-GB). Admittedly, I drive something old and robust enough that a couple of pot holes don't tend to bother me ('91 Triton Ute), but I'm rather surprised at the lack of creativity that has gone into this proposal and it seems like a bit of a step in the wrong direction to me.

There are so many important infrastructure projects that should be put ahead of a 4 lane midlands highway, and before a Kingston bypass for that matter. First and foremost is getting the hospital under control. Coincidentally I was in the RHH earlier today, my wife compared it to the last public hospital she was in (Chiang Mai, Thailand) and the RHH didn't get a favourable report.

Spending huge amounts of money so more cars can fit on our roads seems like lunacy to me. Money would be better spent on:
1. Improving public transport availability.
2. Promoting carpooling and cycling.
3. Implementing free park and ride shuttlebus services.
4. Using the NBN to get businesses to conduct meetings online rather than drive between Launceston and Hobart constantly. Online meeting software is getting very advanced and very affordable - see www.dimdim.com, every Tasmanian business should be equiped and trained with such software.

If dimdim for linux supported desktop sharing I might even use it a bit more myself, but that's a story for another blog post.