$ cat post/cold-bare-metal-hum-/-we-scaled-it-past-what-it-knew-/-we-kept-the-old-flag.md

cold bare metal hum / we scaled it past what it knew / we kept the old flag


Title: A Muttering About Xen and Perl: May 26, 2003


Well, it’s been a while since I’ve sat down to write something like this. It feels almost quaint now, but back in the early days of my career, every day was packed with new challenges and a lot of learning. Today’s date is a bit arbitrary, but I’ll stick with it for the record.

The Setup

It’s May 2003, and I’m working at a small startup that’s just starting to take off. We’re not exactly in the heart of Silicon Valley, but there are enough signs around us that this could be the start of something big—Web 2.0 was still a buzzword, and we were living it. Our stack is pretty standard for those days: Linux, Apache, MySQL, Perl (LAMP). And then, of course, there’s Xen.

We’re using Xen as our virtualization platform because it seemed like the future, especially with Google hiring aggressively and everyone talking about virtualization. We had a few servers running various services—web apps, database stuff, some backend processing jobs—and we were trying to get more out of them without buying more hardware.

The Problem

One day, I’m debugging something that’s been driving me crazy for weeks. It’s one of those “it just stops working” issues where the logs are vague and the symptoms are frustratingly intermittent. The problem is with a service that runs on Xen, but not in the same way as our other services.

I trace it down to a script I wrote a few months ago. This was 2003, remember—scripting and automation were king. We had Perl scripts all over the place, running cron jobs and doing all sorts of useful things. But one particular script wasn’t playing nice in Xen.

The Investigation

The script is supposed to manage our database backups. It starts a MySQL server instance, runs some backup commands, and shuts everything down when it’s done. It was working fine on the bare metal machines we used before, but now that it runs under Xen, things are going haywire.

I dive into the logs, which aren’t exactly helpful. The script seems to start just fine, but then it hangs somewhere in the middle of the backup process. I check the output, and there’s nothing—no errors, no warnings, just silence. It’s as if the script stops working for some unknown reason.

After a few days of frustration, I decide to take a more systematic approach. I start by isolating the problem: can I get the MySQL server instance to start in Xen at all? I write a simple test script that just starts the MySQL service and exits. Sure enough, it works fine outside of our backup script.

Next, I add some debug output to the script. This is where things get interesting. The script reaches a certain point, prints out “Starting database…” and then… nothing. It seems like the process is hanging after that message. But why?

The Breakthrough

After hours of staring at code, I finally spot it: there’s a line in our backup script that runs mysqladmin shutdown to stop the server when we’re done. This works fine outside of Xen because MySQL handles signals properly and exits gracefully. But in Xen, something is different.

It turns out that Xen doesn’t handle signals like traditional Unix does. It has its own way of managing processes and signals, which means mysqladmin hangs waiting for a signal that never comes. I can see now why the script stopped working—the signal didn’t propagate as expected.

The Solution

To fix this, I have to change how we manage stopping MySQL. Instead of using mysqladmin shutdown, I write a small Perl script that sends a SIGTERM directly to the MySQL process. This way, it works in both Xen and our other environments.

I test the new script, and it works perfectly. The backup completes as expected, without hanging or crashing. It’s a small victory, but one that taught me an important lesson: virtualization changes everything, even things you might not expect.

Reflecting

Writing this now, I remember how much of my time back then was spent debugging scripts and dealing with weird behaviors in virtualized environments. Xen was still relatively new, and it wasn’t always well-documented or understood. But that’s what made the work so exciting—figuring out these quirks and making things work where they didn’t before.

As I type this, I’m glad to think that those days were just a small part of my journey in tech. Looking back, it feels like another chapter in an ongoing story. Tech moves fast, and what was cutting-edge then is now history, but the lessons we learn endure.


That’s about it for today. If only I had known then how much this would change over time. But that’s part of the fun—seeing where it all leads.