Timezones on servers

People across North-America are scrambling to update their servers, in order to deal with the upcoming timezone changes.

I’ll tell you a little secret that has served me well… ever since the C libraries were a pest in the mid eighties (the ones on DOS defaulted to GMT-5, US EST, or something in that realm), and since with layers of libraries you easily risk missing a timezone conversion, or get double/triple conversions, I decided to never use timezones on servers again.

In the old DOS days, the library issues were resolved by making an app do setenv(“TZ=GMT0”); tzset(); on startup. No more conversion problems, regardless of the system time.

But in essense I do the same on Internet servers that I manage. They all simply run in GMT and therefore never need to change timezones – and they’re immune to dst funnies invented by George W Bush, too ;-)

On display, an application simply converts from GMT to whatever local timezone is appropriate for the user.
Think about it… countries like the US and Australia have multiple timezones, so which zone do you use for your web site? Would it not be nicest for the users if they got all times in their own timezone, rather than some arbitrary zone that you decide for them – which is based on the -for them- completely irrelevant location of the server (or your timezone decision, whichever).

Easy as – better user experience, with less work and maintenance issues.

Great circle and distances

I reckon that techies sometimes go overboard in accuracy!
Many sites use so-called Great-Circle calculations to find places within a certain distance of a specified location. The resulting queries tend to do full table scans with relatively few actual matches, then order by distance and page or limit that.

If, instead, you use a bounding rectangle and also pretend that earth is flat, life becomes much easier. The resulting queries then will use range scans on indexes. So much faster you wouldn’t believe it.

What’s the difference? Well, accuracy.
For short distances, the earth’s curvature is not significant.
Apart from that, the maximum deviation from the radius is (SQRT(POWER(r,2) * 2) – r) where r is the radius, simply applying Pythagoras’ Theorem.
It comes down to a deviation of about 20 kilometers when looking in a 50 km radius in the extreme corners.

So, if you’re looking for a hotel in the area, or a date (or both ;-), does this extra distance matter? Probably not.
Yes, the effective maximum distance can be 70 instead of 50, but that’s “as the crow flies” anyway.
Imagine if there’s a river between your central location and a hotel, with a few bridges in town – how much further would you need to drive to get to the hotel? Sites don’t take that into account either… absolute proximity is a very relative matter.

Naturally, you shouldn’t use this shortcut on its own for larger distances.
What you can do though is use this trick to efficiently do the initial search, then perform the more accurate great-circle calculation on those results. That’s an extra step, but believe me, it’ll still be much faster.
It can also still be done within a single query.

Please do feel free to post comments about your particular encounter of this problem in your application; and if you have timing information from how you solved the issue in your case, that’d be great.

By the way, I know you could optimise this in some RDBMS with 3D GIS queries, however it should still be more efficient (quicker) to use the shortcut. Popular GIS platforms (such as MAPINFO) use bounding rectangles for pretty much everything under the hood, too…

Networking – people connecting with people

Doing some book packing in my office this morning (moving house soon). I didn’t keep that many books when I moved from The Netherlands to Australia, so at the time I did a very tough selection. Naturally, I wouldn’t toss my copy of “The C Programming Language” ;-)

One book that was given to me by my good friend Jaap van Till a long time ago is “The Networking Book – people connecting with people” by Jessica Lipnack and Jeffrey Stamps (ISBN 0-14-019116-X). It’ll be out of print but I believe Amazon lists some 2nd hand sources. So why is it out of print? Because it was first published in 1986.

In 1986, what did we have… 300/1200 bps modems, FidoNet email, and that’s actually what I was also involved with at the time – designing and coding datacom protocols to help people connect (some of it is actually still in use today).

Some books (and people!) are just way ahead of their time. Certainly the networking we do today goes, in terms of technology, far beyond what the book describes, but it does predict the overall trend very well. The book notes that networking is the natural response to the information technology era, based on individual participation rather than hierarchy. It also accurately describes social networking, linking ideas and resources. Interesting, and I think it helps to read back such old materials and still learn more about why all this works the way it does.

Jaap also quoted me a statistical fact that stuck with me: no country that has more than 1 phoneline per 1000 citizens, has a dictatorship or other totalitarian political structure. Check it out for yourself, I’m pretty sure it still holds true and throughout the 90s we saw the political changes in Eastern Europe neatly coincide with the “connectedness” of the people in those countries.

Once enough people in a group can communicate (through phone, email or other reasonably fast means) with others outside their local group, you simply can’t control them and their thoughts. It moves too fast. My point here is that it’s a seemingly unrelated thing, but with very broad effects. You can use this indirect measure to see how different countries are doing, and whether they’re moving in the right direction. Many are, I think.
Revolution is nasty and often unnecessary. Evolution on the other hands is pretty much unstoppable. It just keeps happening, and things sort themselves out in due time.

So could you overthrow a dictatorship by setting up say a mobile network? Nah, because the phones and the dictator are only two aspects in a big interconnected structure. Nor does removing the dictator and holding elections make a democracy. We’ve seen that one actually tried, right? One can’t over-simplify. Lots of aspects need to converge to make it all work. But in the right context, networking is a very potent factor and interesting to watch (and of course, participate in).

Let me know if you want to borrow my copy of the book – right now it’s going into the moving box, for safe keeping and later reference. Thanks again Jaap! You’re a wise fella.

OSDC 2007 – Brisbane – we got the gig!

So, OSDC 2007 (Open Source Developers Conference), held in Melbourne in previous years, will visit glorious sunny Brisbane this year (end November, early December).

My thanks to Anthony Towns, Andrae Muys and James Iseppi for helping me with the legwork and homework to put together our submission, and to the OSDC committee for giving us this opportunity – it’ll be good.
More news (including the exact dates and venue) soon, Andrae is already preparing the Call for Papers.

If you are interested in helping and haven’t written to me before, now is a good time.
Likewise, if you would like to sponsor this event, getting in early could get you an honourable mention even as early as the call for papers… that would get you nearly 10 months worth of exposure and good karma!
We actually received quite a few expressions of interest for sponsoring already; we’ll be attaching sponsorships to specific components/events of the conference, so this means that you can align your contribution with something (like a lunch, morning tea, a specific track, or the conference dinner) that best fits your company. First come first serve….