You’re reading Signal v. Noise, a publication about the web by Basecamp since 1999. Happy !

Mark Imbriaco

About Mark Imbriaco

Ran ops for 37signals, Heroku, and LivingSocial.

Nuts & Bolts: Campfire loves Erlang.

Mark Imbriaco
Mark Imbriaco wrote this on 39 comments

A couple of years ago a lot of buzz started in the Ruby community about Erlang, a functional programming language developed by Ericsson originally for use in telecommunications systems. I was intrigued by the talk of fault tolerance and concurrency, two of the cornerstones that Erlang was built on, so I ordered the Programming Erlang book written by Joe Armstrong and published by the Pragmatic Programmers and spent a couple of weeks working through it.

A year later, Kevin Smith began producing his excellent Erlang in Practice screencast series in partnership with the Pragmatic Programmers. It’s amazing how much difference it made for me to be able to watch someone develop Erlang applications while talking through his thought process along the way.

As I was learning Erlang, I kept threatening to rewrite the poller service that handles updating Campfire chat rooms when someone speaks in room. At some point my threats motivated Jamis, who was also playing with Erlang in his free time, to port our C based polling service to Erlang. Jamis invited me to look at the code and I couldn’t help myself from refactoring it within an inch of it’s life.

The code that Jamis wrote worked fine, but it was not very idiomatic Erlang. While I didn’t have much more experience developing Erlang code than Jamis, I had definitely seen more real Erlang code. I tried to pattern our work after what I had been exposed to, making improvements along the way. We ended up with 283 lines of pretty decent Erlang code.

parameter(Parameter, Parameters) ->
  case lists:keysearch(Parameter, 1, Parameters) of
    {value, {Parameter, Key}} -> Key;
    false -> undefined
  end.

For the curious, here’s a very simple example function from the real Campfire poller service. This function takes two arguments, the name of a parameter to search for, and the list of parameters. If it finds a matching parameter it returns the associated value, otherwise it returns the atom undefined. Atoms are like symbols if you’re a Ruby programmer.

Last Friday we rolled out the Erlang based poller service into production. There are three virtual instances running a total of three Erlang processes. Since Friday, those 3 processes have returned more than 240 million HTTP responses to Campfire users, averaging 1200-1500 requests per second at peak times. The average response time is hovering at around 2.8ms from the time the request gets to the Erlang process to the time we’ve performed the necessary MySQL queries and returned a response to our proxy servers. We don’t have any numbers to compare this with the C program that it replaced, but It’s safe to say the Erlang poller is pretty fast. It’s also much easier to manage 3 Erlang processes than it was the 240 processes that our C poller required.

Erlang definitely isn’t a replacement for Rails, but it is a fantastic addition to our collective toolbox for problems that Rails wasn’t designed to address. It’s always easier to work with the grain than against it, and adding more tools makes that more likely.

Nuts & Bolts: HAproxy

Mark Imbriaco
Mark Imbriaco wrote this on 28 comments

A common request we get from readers is to describe in more detail how our server infrastructure is setup. That question is so incredibly broad that it’s hard to answer it in any kind of comprehensive way, so I’m not going to try to. Instead, I’m keeping the general desire for more technical details in mind as I work through day-to-day issues with our configuration, and I’ll try to occasionally write about things that I think might be of interest. The topic for today is HAproxy.

Continued…

Amazon S3 Stats

Mark Imbriaco
Mark Imbriaco wrote this on 16 comments

There was a lot of interest in the Amazon S3 statistics that we posted a while back, so I thought I’d follow up with some more current data. Here’s a quick summary that I whipped up this morning showing our Amazon S3 usage stats since the beginning of the year.

Fun with stats, the S3 edition.

Mark Imbriaco
Mark Imbriaco wrote this on 39 comments

Whenever I get the email from Amazon telling me that our monthly bill for web service usage is available, I take it as an excuse to spend a little while looking at our usage stats and how our storage needs have grown.

When I started working at 37signals in October of 2006, we were using less than 1.5TB of disk space for customer data for all of our applications and were starting to get to the point where redundancy and backups were becoming a headache. Shortly after I started, we decided to give S3 a trial run with Campfire and we became believers pretty quickly.

The fact that S3 is priced so reasonably (our last bill was $2,004.12) and the fact that it’s generally hassle free has enabled us to drastically increase the storage limits for all of our applications. Not having to worry about managing the file servers and backups is a pretty nice bonus as well.

Here are some stats from last month, and from October 2007 to compare how things have changed over the past 6 months.

Continued…

Mini-Review: Amazon Kindle vs. Sony Reader

Mark Imbriaco
Mark Imbriaco wrote this on 17 comments

Several months ago I wrote a brief review of the Sony Reader (PRS-500). The upshot was that I was extremely happy with mine, with just a couple of small caveats. Fast forward to today and I now have something else to compare it with, the Amazon Kindle.

There are plenty of comprehensive reviews of the Kindle floating around so I don’t think we need another one. Instead, I’ll focus on comparing it with the Sony Reader.

Continued…