Monitor Redis Pubsub Messages

Do you need to monitor your redis data store, but rather than see everything under the sun only want to see the messages published in the pubsub?

redis-cli monitor | grep -E ' "PUBLISH" '

Piece of cake, and so helpful for tracing through to find the source of issues in a complex system.

Any Fool Can Code

Scott Ship’s post Why Senior Devs Write Dumb Code resonates with me.

I love the quote from Kent Beck’s book, Refactoring: Improving the Design of Existing Code:

Any fool can write code that a computer can understand. Good programmers write code that humans can understand.

I love this. As a software engineer with many, many years logged in the industry, I still write very basic code and try to never be too “clever”.

This Blog Runs on MariaDB

I have written a lot about databases over the years, primarily MySQL. ~300 posts on this blog, a book titled ProMySQL, and another book on MySQL Cluster Certification. In a former life I worked extensively with MySQL, never as a DBA, but a devops guy who had ownership at all levels of the stack.

This week when migrating to a new platform I chose MariaDB to power this blog.

Why? There are some fairly significant events since I worked so closely with MySQL. MySQL was bought by Sun Microsystems. Then Sun was bought by Oracle. With uncertainty around the future of MySQL, many of the primary players in the original development and industry adoption of MySQL ended up coming together to form MariaDB. MariaDB is a fork of MySQL, a drop-in replacement that lives squarely in the open source ecosystem.

Now with 12 million users worldwide, and MariaDB just landing a $27M investment from Alibaba, it feels a lot like the best days of my time working with MySQL.

Personally, for some years now my day jobs have been more squarely focused on leading/directing teams, writing business logic, and working in services-oriented architecture where I’m more on the side of consuming services APIs than doing backend work. Not a lot of backend, database work. I realize powering this blog with MariaDB won’t really offer any significant chances to work at the database level, but it feels a little like coming home to choose it and have it as this blog’s foundation.

Migrating from MovableType to WordPress in 2017

With some server shuffling happening recently this blog appeared to be on the chopping block. Didn’t take much poking around to remember how much history there is here and feel like it was worth finding a new server home, and hosting platform. 1012 blog posts from 2003 to 2013! That is a body of work! I suppose of debatable value.

Despite it being 4+ years since I last posted, and 14+ years since I started writing on MovableType (which is now only available commercially), there was still a very usable article on migrating to WordPress (as Stephen Rosenberg says “the software that swallowed MovableType’s user base whole”).

2003 was a long time ago, an eternity in internet years. Before smart phones and tablets. Before Hybrid cars. Before mainstream adoption of blogs, when blogging was something a small number of geeks did. I’m really happy that all 1012 posts migrated with everything intact, pictures, links. Even more, the instructions included details for maintaining URL structure so links to posts and search engine indexing would work seamlessly.

Next post scheduled for 2021 🙂

Still Loving The Postal Service

10 years ago the band The Postal Service released their only full length album, Give Up. Back then they did a live studio recording at KCRW on their Morning Becomes Eclectic show. I had the video on my bookmarks for a long time but changes in the website some years back meant no more video. A few times I went trying to dig and find it, but no luck.

This morning I found a recently uploaded version of the video on YouTube:

In 2013 The Postal Service is touring, coming to Boston, and yes I have a ticket.

Andriod to iPod/iPhone Dock Adapter Cable

I’ve gotten a Zune connected to an iPod/iPhone dock in the past, but what seems more compelling these days with the rise of Android is to make an adapter or a cable to get a micro USB device to an iPhone, iPod, or iPad docking station.

Important caveat: it’s technically impossible to provide the same kind of device integration that an iPod/iPhone car or speaker system provides; audio, video, track and playlist control, viewing track information on the car system, etc. Those are things that Apple’s 30-pin docking adapter all have built in, which is why it is so compelling and revolutionary. A micro USB connector can only really charge and sync a device, it doesn’t not have the connections to do all that fancy integration.

I wish there wasn’t this caveat. However, if you’re willing to accept the compromise that Android integration cannot match what Apple provides, but want to at least get something out of that iPod/iPhone speaker or other docking system, there’s a way.

Apple’s dock connector (the 30-pin plug on the bottom of the iPhone, iPod, and iPad) provides many functions. Most Android phones include two jacks; a micro USB connector for charging and syncing, and a standard 1/8″ (2.5mm) audio jack for standard headphones. The pins for these two connectors on Android phones can be isolated on the 30-pin connector and provided for CableJive’s dockBoss+ adapter cable does exactly this, it lets you plug a smart little adapter onto your iPod or iPhone speaker dock or car system, and provides a micro USB and audio cable so you can charge your Android phone and listen to audio, both through your docking system.

It’s not the ultimate solution, but until Apple decides to open up their proprietary communication system (never going to happen), getting micro USB and audio to connect an Android phone to your iPhone, iPod, or iPad dock at least keeps your phone charged and the music playing.

Ruby on Rails 3, Octopus, and Sharding with Groups

The Ruby on Rails app I’m building from the ground up needs to be able to handle *lots* of data. From the get-go I’ve known I’d need to put some kind of data partitioning to make this thing scale, but just finally tackled it this week.
Rails doesn’t come with a built-in ability to connect to multiple databases, but there are lots of folks who have tackled it. Ryan Tomayko’s post Rails and Scaling with Multiple Databases (written way back in 2007) is a good indicator that there are folks doing serious business with rails and multiple databases, and has some good links to other sources.
I was looking at writing something myself, but in digging around came across Octopus a few times and realized it does exactly what we need, data sharding with the ability to programmatically select databases in controllers and models, as well as good migration handling.
For the application we’ll have a master database which centralizes account, user and session information with a pointer to the appropriate data shard. Once a user request has been authenticated, the actual application data gets pulled off of one of the shards they’ve been assigned to. The master database has a simple schema for user, account, and session information, the schema on the shards is significantly more complex, but the same on each shard.
Octopus documentation is there, but not extensive. Through some trial and error I found that the following shard.yml configuration file was what I needed (the Octopus documentation doesn’t spell out how to use shard groups in a rails environment, but it makes sense once you get it working). The master shard for the environment is defined in database.yml.

octopus:
environments:
- development
- test
- production
development:
data_shards:
data_1:
adapter: postgresql
database: dev_data_1
username: something
password: cryptic
template: template0
data_2:
adapter: postgresql
database: dev_data_2
username: something
password: cryptic
template: template0
...

It’s obviously paramount that the models know where to connect for their data. When a user authenticates I invoke ActiveRecord::Base.establish_connection() to connect to the shard so it’s the default data source everywhere in the application for that request. Requests that need to interact with the master database are handled in the controller:

around_filter :select_shard
def select_shard(&block)
Octopus.using(:master, &block)
end

The other important piece of this is migrations. Octopus works well for our needs here. When a migration is written it either needs to update a single master database or be applied to all data shards. This is where shard groups come in. To apply a migration to all shards we specify the group with using_group() method, and the migration then runs for each shard in the specified group.

class CreateInventoryEvents < ActiveRecord::Migration
using_group(:data_shards)
...
end

Pretty slick, happy with Octopus from a functionality perspective. Not sure about scalability and the overhead to move requests between database connections, will dig more into that next.

Developer Happiness at Etsy

Listening to Chad Dickerson (CTO at Etsy) speaking about optimizing for developer happiness at RailsConf 2011.
Etsy releases software 25 times a day with 75 engineers. They emphasize constant progress with a radical decentralization. It shouldn’t work, but they are built on trust. There is one button that folks can press (after some fanfare) that pushes code up to production
They’ve had developers push code on their first day, they’ve had board members deploy code.
Chad contrasts industrial revolution assembly line times with how Etsy works. Etsy highly prioritizes letting the developers be human, having lunches together, having offices that are full of creative, fun stuff. Dogs have deployed code by guiding a paw to pressing the button.
Releases are done with a self-managed push queue, developers put their names in a queue kept track of in an IRC topic. When the first person in line pushes and is clear he/she notifies the next in line.
Remember, your team is your community. Help people finish things and see their progress.
Optimize your teams for the happiness of people.

Glenn Vanderburg on Building Software

Fantastic closing keynote by Glenn Vanderburg at RailsConf 2011 about software engineering.
Great ideas about software engineering and how it compares to classical engineering disciplines (civil, structural, industrial, mechanical, electrical, traffic, etc). Compares the definition and process of structural engineering to software engineering.
Is software engineering or craftsmanship? In software, the documentation that is required by other disciplines is actually the artifact that gets built in software engineering. Classical engineers diagram, plan, document, model and then take those and build the artifact. Software engineers diagram, plan, document, and model as a part of building the actual artifact. Also interesting, software is changing the way classical engineering works, a lot of software being used in the planning process to understand how the actual artifact
We are designers and builders. Software has to be the solution and describe the solution.

Programs must be written for people to read and only incindentally for machines to execute.
Harold Abelson and Gerald Jay Sussman

We are engineers and craftsmen.

Software Version Numbers

In the RailsConf 2011 RubyGems presentation this afternoon, Nick Quaranto spent some time talking about versioning software, showing the versioning of TeX as kind of crazy where they use PI, adding a new digit of PI on the end of the software version number for each release.
Nick suggests that Semantic Versioning is the best methodology. Read more at http://semver.org/
The idea is:
1.2.3 (major.minor.patch)
major versions – for major releases where there may be some backward incompatible changes
minor versions – for minor changes, no API or other changes that make it incompatible with previous versions
patch version – for fixes, improving stability