Monday, May 12, 2008

The Coolest Things from Ironman

Ok, so, everyone knows the Iron Man movie is great. If you haven't seen it:

1. Don't read any further (spoilers)
2. WHAT THE HELL ARE YOU THINKING? GO RIGHT NOW.

Right, now the legalities are out of the way..

i loved the movie for many reasons, but post-watching, a few things stuck in my mind:

1. Robot arms with fire extinguishers!
2. Being able to fly (totally cool)
3. The Anti-Tank Missile complete with Comedic Timing Device
4. Mini-reactor that glows!
5. I love that house. I love it. I want it. And the windows too.
6. Virtual ex-britas butler with sarcasm module
7. Delicious on-screen graphics

But one of the most relevant things was:

8. A competent PA

I don't have a PA. I'd like one tho. My ability to keep a consistent calendar, or todo list, or anything, is pretty weak. I try, but software has not yet evolved to the point where it can keep me organised. Sadly, I can't afford one, nor can I afford a hilarious robot arm or a house built into a cliff in Malibu. Still, I can dream right?

Friday, May 9, 2008

HORRAY!

I have finally got internet at my new place again. No more slow cellphone connection for meee...*joy*

Sunday, May 4, 2008

Caching is stupid

Before you freak out, let me run with this one for a bit, it's based on some very practical experience.

Caching is one of those things we instinctively turn to when we hit some kind of performance bottleneck within a web application - after all, the web is pretty much designed to be cached and has all these lovely headers and things, so it seems to make intuitive sense that if your stuff might get cached out there, you may as well cache it in here.

The problem is that caching actually implies a serious problem, one that we often simply accept without any real thought: the authoritative source of our data is too slow to deliver the information accurately as fast as it is required.

Now, sometimes this is reasonable - if you're delivering an aggregated RSS feed then fine, you need to keep a cached copy of the source data for a while because it would be rude to hammer other peoples servers for every request.

Other times, however, it's actually just bad, and it's mostly the fault of the RDBMS.

We in the web community have become so used to the authoritative-database model of life that we refuse point-blank to delegate authority to any other system. After all, the RDBMS has all kinds of good things like ACID which will ensure your data is always consistent etc etc.

The problem is that data consistency has become this strangely religious holy grail. Never mind that foreign key constraints slow the living crap out of your inserts and updates, never mind the fact that in many cases using an ORM means you'd never have an invalid reference anyway, never mind that many people understand transactions in a database so poorly that they simply ascribe them magical powers of correctness they have no hope of guaranteeing, it's still "database or nothing!"

I remember the first time I got thrown out of that comfort zone. In 2000 I was in Sydney working for a great company called Iguana as their systems/linux guy. We were struggling pretty seriously with the huge load of information we were pulling in from the NZX and ASX and our database server was a monster. Scott Cooper - to this day my example of an brilliant programmer - was the programmer there, and simply did the obvious thing - he wrote a C daemon that stored the data in-memory, with basic checkpointing and methods for doing data catchup etc. As with everything Scott wrote, it was a work of art and brutally fast, leaving the database in the dust, relegated to dealing with historical data at its slow, databasey pace.

Since then I have rarely come across a situation where a database didn't do the job in an acceptable timeframe, but there have been a few. In every case, my initial instinctive solution was to install memcached and "do something with it". In many cases this was fine, but in a few situations it was a serious, serious error. Case in point, the most recent Entrecard release involved getting rid of half the caching we were doing - which was failing to provide accurate results, and generally screwing up - and replacing the data source entirely with an in-memory daemon that acted as the authority.

This daemon was written in python using the Twisted framework - a solution that allowed me to access data without contention issues. Careful coding meant that there were basically no loops at all within the code, preventing any possibility of lockup and providing very consistent timing for individual operations. The database had grown so large (millions of rows) that providing an accurate balance for an individual user took upwards of *3 seconds* per request, and the parallel nature of the balance modifications meant that it wasn't possible to "cache" the result effectively or accurately.

The daemon, however, consistently delivered a perfectly accurate balance in-flight in under 0.001s, dramatically improving our ability to scale The daemon also took over a number of other high-contention operations, including managing the card drops. This allowed us to return to the "glory days" of Entrecard where drops were counted immediately and the balance was always up to date, rather than the sad state of affairs we had recently where drops were processed "some time later" by a batch processing system.

Next time you're having performance problems and you start thinking about caching, queues, batches etc take a second look at your architecture - is your current authoritative data source really the best solution to the problem? perhaps rather than using a cache to wallpaper over your problem, you'd be better off creating a data source that can deliver the data at the rate you really need.

Labels:

SuperHappyDevHouse

A quick note, assuming I wake up in the morning, I intend to be at the Wellington,NZ SuperHappyDevHouse at Southern Cross (the garden bar) on the 4th of May (today), I'll be doing a bunch of statistical analysis on Entrecard, drop by and say hi if you're around, many people there know me so just ask around if you don't.

Friday, April 18, 2008

Oops

To everyone who offered kind words in the comments of the last post, thankyou! I hit "Reject" in the moderation screen by accident, I didn't mean to delete them! sorry :/ on a positive note, things are much better today :)

Wednesday, April 16, 2008

Days like these

There are days that are challenging and difficult, where you're juggling a thousand things and rushing to get things done but there's still some kind of satisfaction in the work, in knowing that you're moving forward.

Today was not one of those days. Today was simply depressing. I know depressing isn't fun to read but, well, in the tradition of livejournal it's not really a blog if there isn't some whining self-pity.

In a sense today, or at least, some day this week, was supposed to be a little triumphant - the huge change we made to Entrecard last week has pretty much stabilized, and in some world where I'm a gloating idiot I'd be saying "hah take that doubters!" but the fact is that that's pretty much the only positive thing that's happened this week and I met it more with a feeling of vague relief than actual joy.

In other areas of Entrecard I've been struggling, we've had people trying to hack the security gear on the drop system, we've had severe load problems on the database, the queue manager which is supposed to help hold things when the database can't keep up started losing chunks of data, some brainless idiot sent a death threat to another Entrecarder which means I'm going to have to go dig through a bunch of logs to find out who it was, and it's not like I don't have a thousand things I should be doing for EC anyway, let alone my other clients.

I'm trying to move house this saturday, struggling there as well, I gave up any thought of trying to actually do a full move so now I'm just trying to get rid of my furniture and stuff so that all I have to move is boxes. M3 command adhesive is a total fraud, we have ripped wallpaper because of that, goodbye bond.

That's just the stuff I can talk about in public. Beyond the point where you are desperate or in a hurry, there's a place where you're just a zombie, putting one foot in front of another with no real hope or expectation that you'll manage to get anywhere, dealing with whatever is right in front of you because there is so much high priority stuff that there is no hope of taking any kind of control of it. I am phi's zombie twin.

I got a personal shock today, and it's thrown me a bit. My mother once told me that a person needs multiple things in their life they can take pride in, so that if something goes wrong with one they can draw strength from the others. She told me that when I was really embedded in a work situation that had gone bad and I was really upset about it.

Well, I pretty much followed that advice since, but stuff has been going bad in pretty much every area in the last week and I've gotta say, it isn't any fun. Ah well, ce la vie, just keep on keeping on until the sun shines again.

Sunday, April 6, 2008

Dev day, rants etc

For those who asked what I recommend as a web platform, the basic answer is I don't. I personally use Turbogears, a python-based framework - it works really well for me, but the key thing is that pretty much any of the next-gen platforms (or should I say "current-gen") are a huge step up. Much of it comes down to the way in which you like to code - some of the frameworks work better for people who like working in text and coding, others work better for people who like wizard-based construction and auto-templates. Go experiment.

Dev day at Entrecard went really amazingly well, while the 8am session was dead that was perhaps to be expected, the rest of the sessions had plenty of people, lively discussion, and I managed to implement most of the features people suggested on the spot.

I've got to say, just before the first session I thought to myself "You're mad, why are you doing this? nobody implements features on the spot, it's just stupid", but damn if I didn't manage to pull it off.

In the end I see it as a fundamental statement about what we are - other places try and tack a shiny web2.0 appearance onto an outdated technical approach, this was as bold a statement as I knew how to make for saying "we live and breathe agile". Also, it was great fun, and we got some fantastic ideas.

Also, full credit to Mibbit for their ajax IRC client, the embedded version performed perfectly and let us provide an easy, robust chat platform without putting any load on our server.

Labels: , , ,