Hacker News new | past | comments | ask | show | jobs | submit login
Upgrading Airbnb from Rails 2.3 to Rails 3.0 (airbnb.com)
84 points by Airbnb-Nerds on Jan 4, 2012 | hide | past | favorite | 27 comments



That timezone issue (further described here: http://www.benjaminoakes.com/2010/11/23/rails-timezones/ ) sound like an odd one - anyone know what the underlying cause of the problem is?


In 2007 DST changed and Mexico did not follow suit, so the short PST/EST/CST timezones were not specific enough anymore. Here is an excerpt from Wikipedia (http://en.wikipedia.org/wiki/Pacific_Time_Zone):

Effective in the US in 2007 as a result of the Energy Policy Act of 2005, the local time changes from PST to PDT at 02:00 LST to 03:00 LDT on the second Sunday in March and the time returns at 02:00 LDT to 01:00 LST on the first Sunday in November. Canada would also acknowledge this change. In Mexico, beginning in 2010, the portion of the country in this time zone uses the extended dates, as do some other parts. The vast majority of Mexico, however, still uses the old dates.


If timezones aren't good enough to display the time, what good are they? If Mexico is calling PST/PDT a different time than everyone else, shouldn't they be using new values instead?


The timezone names most countries use are not unique or entirely stable as time goes by. E.g., America and Australia disagree about what "Eastern Standard Time" means. That's why the Olson/Eggert database names zones for major cities, those are most stable and well known.

http://en.wikipedia.org/wiki/List_of_tz_database_time_zones


> America and Australia disagree about what "Eastern Standard Time" mean

EST = Eastern Standard Time (East US)

AEST = Australian Eastern Standard Time (East Aus)

Occasionally we use "EST" as a shortened form of "AEST", but it's rare.


I like that you broke out and completed preparatory steps ahead of actually upgrading Rails, but the blog post points out some process smells.

Title Upgrading Airbnb from Rails 2.3 to Rails 3.0

Date January 4, 2012

Why are you blogging about upgrading to Rails 3.0.x when the current stable Rails has been 3.1.x for over 4 months?

> Our app was running Rails 2.3.8 at the time, and the production instances were a mess. Each instance had its own set of gems and its own versions of those gems. Naturally, none of the instances matched.

How did this happen?

> Tobi listed every controller in our app at the time and divided them among the engineers. The engineers went through the templates used by each controller and made sure string output in templates was marked as html_safe or rendered with raw where appropriate.

Most of the XSS work was done in a single day with all of the engineers' help, but there was cleanup on pages that weren't used very often that continued for several weeks after installing the plugin.

Why look at the controller granularity for templating bugs? If any controllers share a partial or helper, you may have engineers stepping on each others' toes.

Also, shouldn't these simple bugs be quickly and fully discovered by automated tests?

> We knew the real upgrade required major code changes, so four engineers started the upgrade on a Saturday afternoon when there were minimal changes being committed. We asked other engineers to hold off on changes over the weekend to prevent any merge nightmares.

If the upgrade is done on a branch, why must the work be completed during the weekend?

And why must you block changes generally for an entire weekend because of work done to a single branch?


> Why are you blogging about upgrading to Rails 3.0.x when the current stable Rails has been 3.1.x for over 4 months?

Like mentioned in another comment, upgrading from 2.3.x to 3.0.x is a feat in itself. Upgrading from 2.3 to 3.1 might be doable on a smaller project, but with code written in several versions of Rails we decided to go 2.3 > 3.0 > 3.1.

> Also, shouldn't these simple bugs be quickly and fully discovered by automated tests?

There was plenty of HTML inside Ruby statements in our templates that started being escaped. Something like:

<p><% (price > 10) ? '<strong>Expensive!</strong>' : 'Cheap' %></p>

while ugly was not wrong. This is a very simple version of some of the problems we saw, and there were typically several per template. Writing tests that check the HTML output of template files would be unmaintainable.

> If the upgrade is done on a branch, why must the work be completed during the weekend?

To avoid a big merge. We changed a lot of files and didn't want to have to re-check our work after letting Git auto-merge our changes.


> Why are you blogging about upgrading to Rails 3.0.x when the current stable Rails has been 3.1.x for over 4 months?

They switched to 3.0 quite some time ago:

> Our production instances made the final switch in the week leading up to Thanksgiving

Writing this blog post probably wasn't very high priority.

> How did this happen?

Maybe they were busy creating a great product instead of obsessing about perfect architecture and optimising prematurely?


Maybe they were busy creating a great product instead of obsessing about perfect architecture and optimising prematurely?

I think you'll be hard pressed to find anyone who believes that ensuring all of the servers are running the same code is a 'premature optimization'.


> Also, shouldn't these simple bugs be quickly and fully discovered by automated tests?

Do you actually believe this?

Tests are a nice first pass, but they'll never fully discover every bug -- especially with a huge change like this.


Exactly as painful as it might seem. Automated tests can only get you so far. Sometimes you just have to suck it up and dig into the code base.


From what I understand, the convention in the rails community has been to upgrade from 2.x -> 3.0 -> 3.1.x than to go full bore 2.3 -> 3.0.

Edit- left out a word


Furthermore:

> Clone the rails3 branch into a separate directory from the usual working directory (instead of simply switching branches)

What does this accomplish?


When I've done similar upgrades, I've often found it quicker to have the previous code available to me in another checked out repo rather than switch branches and have to deal with any possible uncommitted changes issues.


You can also use git stash for that.


3.0.x is more different from 2.3 than 3.1 is to 3.0.


Why are they blogging about it now? Look at it as advertising.

Air BnB haven't been in the news for awhile and sales have been slumping, so they coughed up this hairball of a post to stay "top of mind".


I'm just as interested in knowing what happened after the upgrade. How's performance on 2.3 vs. 3.0? Are there plans to upgrade to 3.1 anytime soon? Has using 3.0 increased developer or ops productivity in any measurable way?


Assuming they were already running Ruby 1.9.x, they probably saw a smallish increase in response times moving from 2.3 to 3.0. I've seen that on two separate, large projects.

There is a drastic decrease in response times with switching from 1.8.7 MRI or 1.8.7 REE to 1.9.x MRI.


A killer when I upgraded my blog was the builder changes in 3.1 ... they added a param that killed fast_xs http://stackoverflow.com/a/7257363/17174 without fast xs you have no hpricot and woeful perf http://samsaffron.com/archive/2008/03/29/Speed+up+your+feed+...


Thanks for the post but I just worry our app won't be as easy to upgrade. We've got a Rails 2.3 app that I'd really love to upgrade ...

Did you not encounter any gems/plugins that broke after the upgrade? (we've got a hacked version of attachment_fu for images)


What were the reasons for upgrading to Rails 3.0 in the first place?


Are you asking why one might, in general, prioritize that upgrade? Rails 2.x to Rails 3 is a pretty big deal. For a huge production site, the "Merb-ificiation" (modularization) of Rails might be a performance/maintenance win.

(I have no idea why Airbnb in particular upgraded, but the 2->3 upgrade is in general very much worth it --- the new router and Arel alone are sufficient wins).


One of the major reasons for using a framework like rails is to take advantage of open source code that frees you to spend time focusing on your company's core competencies. Some of the most useful gems in the rails ecosystem no longer (or never did) support rails 2. This is the biggest reason in my mind, but release notes on rails 3 itself are here http://edgeguides.rubyonrails.org/3_0_release_notes.html


An amazing feat seeing that airbnb doesn't employ any programmers (I know that because the interface bugs I reported as a paying customer were handled by the PR department or simply ignored).


Sometimes at a startup you just don't have the resources to do everything. Upgrading to Rails 3 pays down their technical debt substantially and will help prevent interface bugs like the ones you encountered in the future.


This particular startup had VC money flooding them from all directions. The bugs are still there. One involves credit card access between users, the rest are trivial (the stuff you'd let a junior programmer handle). Upgrading to Rails 3 doesn't magically solve anything.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: