November 5, 2009

Let’s talk about something incredibly geeky, the dreaded ALTER TABLE…

justinday:

If you’ve done any work on a highly scaled website the words ALTER and TABLE are probably two of the scariest words you’ve ever encountered. Nothing is worse than locking a really important and heavily used table for some undeterminable amount of time. Seconds turn into days, minutes into lifetimes. Okay that’s an exaggeration, but you get the idea.

There’s two techniques we use at blip to avoid the dreaded ALTER TABLE: vertical tables, and reverse replication rollout. In this post I’ll only talk about the vertical table.

Vertical tables are pretty common, anyone who has scaled a site probably has use them. There doesn’t seem to be any consensus on an exact recipe. The basic premise is to make a table with key/value pairs instead of adding new columns. You generally put data in these tables that isn’t used that often, but that you still need to be able to track.

At blip we set it up like this. Our vertical tables are called attribute tables. So for users we’ll have a user_attributes table that has a user id, an attribute name and a value. We also have a defaults table that contains a list of all the valid attributes, their description, and a default value. This allow us to keep the number of rows in the attributes table as small as possible by only including non-default values. It also allows us to generate an admin page pretty easily. The defaults table is super heavily cached and the attributes themselves are lazy-loaded and cached as well.

Now when we want to add a new attribute we just insert a row into the attribute defaults table and purge the defaults from cache. All the caching and lazy-loading also helps performance by not querying for data we don’t often need. You gotta watch your developers though, make sure they set the proper default value in the defaults table, or you’ll end up adding a new row in the attributes table for almost every user.

This would’ve been more clear with a picture, let me know if you’re confused. Does anybody else make heavy use of vertical tables? How do yours work?

July 5, 2009
On the Web, producers have this delicious freedom to produce content as long as it should be. They’re starting to take advantage of that.

New York Times media writer Brian Stelter just published a great piece: Rise of Web Video, Beyond 2-Minute Clips.

In it, he chronicles something our head of content, Eric Mortensen, began noticing last fall: that shows with longer episodes, such as Nostalgic Critic and Momversation, were starting to really take off.

The trend has continued, showing something pretty significant happening in the market - people are watching Web shows like they’d watch TV shows, and no longer just snacking, but staying to watch entire episodes, even if they’re ten, fifteen or twenty minutes long.

(via bliptv)

(via evangotlib)

(via asonnenberg)

(via mikehudack)

May 25, 2009
May 14, 2009
May 13, 2009
Engineering Rapleaf - “Multi-threaded” MySQL Replication

defeating replicating lag by splitting slaves into 2 processes, each which have half the tables. Replication is a single-threaded process so this “multi-threads” it . Requires code-level changes to grab the right “partition” though

Engineering Rapleaf - “Multi-threaded” MySQL Replication

defeating replicating lag by splitting slaves into 2 processes, each which have half the tables. Replication is a single-threaded process so this “multi-threads” it . Requires code-level changes to grab the right “partition” though

May 2, 2009
We “dark” launched the client a couple weeks before the inauguration, which meant deploying some Javascript code that would get executed transparently on users’ home.php. The code would make requests to our backend periodically, exercising our entire stack, including client, front end, and backend code. We could throttle the dark launch up and down to simulate different request rates and types and test various contingency mechanisms and failover levers we had in place. This was about as realistic a test as we could achieve, and allowed us to ferret out bugs and infrastructure and performance issues well before inauguration day.
April 9, 2009

In my 3-day test, Dynect demolished the others. It was more consistent and had a much lower average response time.

Average DNS response times (and Std. Dev)
dynect.net: 42ms (60)
netriplex.com: 78ms (109)
ultradns.net: 80ms (448)

April 2, 2009
March 18, 2009

Open Files in Photoshop from Terminal

As I progress towards a pragmatic (and programmer’s) approach towards managing design files with version control, I needed a way to open files in Photoshop and other applications from the Terminal command line.

Since I am not a programmer, I decided to write a simple shell script to run my command. To do this (on a Mac), I created the file ‘psd’ in /usr/local/bin/ with the following code:

open -a “Adobe Photoshop CS3” “$@”

Next, I updated my bash profile to allow me to execute this from anywhere within my file system. To do this, I opened up my ‘.profile’ (located in ~/ or /Users/-username-), and added the following to the end of the first line:

:/usr/local/bin/psd

Now, from anywhere within the file system I can type the following to open the file in Photoshop:

sh psd filename.psd

This is much nicer than writing out the long “open -a …” command. This, of course, can be done for other applications, such as indd for InDesign, ai for Illustrator, etc.