We’ve been finished with Chow for about a month now and that feels great. (PJ wrote about the launch back in the day.) The site is stable and it’s our second from-scratch Rails site at CNET, the first being Chowhound. Party time, right? Right.
Since it seems like we did something correct, I’d like to share with you our toolbox. We have no golden hammer, but we sure use some kickass open source software. So here’s a high level overview of what we got. Maybe a hammer or tape measure you find within will be new and useful to you. One can only hope.
Servers
The muscle, scar tissue, and bone behind our sites are not unusual. Rails convention: a hardware load balancer to Apache 2.0 to Pen to a cluster of Mongrels. Coda Hale has an infamous tutorial on setting up a similar architecture and Zed maintains a stellar documentation page over at the Mongrel site. We’ve had very few problems with Mongrel, and Pen is so quiet that I often forget it exists.
Behind the backend we run an installation of Solr as our search engine. It’s Java, but a nice XML-RPC API helps alleviate the pain. A dedicated wiki page is available with Ruby help (which you probably won’t need). A cron or two is needed to insert items into the index, but that’s it.
We (of course) run memcached and use it to cache tons of data. This helps keep our site speedy and takes the load off our largeish database. In case you missed it, a previous Err post touches on memcached. It’s a lot easier to use than you might think.
Finally, we use MySQL for our database. Big surprise there.
Deployment
Like any red blooded America, we use Capistrano for deployment. There’s really no other option. The mailing list is invaluable, as are the various tidbits scattered across the internet. There’s even a great cheat sheet.
We also use monit to handle our production environment. monit is a nice program which provides a web interface for monitoring your apps. It will restart wayward processes and e-mail you when trouble arises. On top of that, it can also watch to make sure daemons don’t take up too much CPU or memory and kill them when they do. It uses a nice little DSL for its config files and, as long as you have a pid file, is easy to get up and running. There’s a nice starter monit config file here and plenty of resources out there. monit can even replace mongrel cluster. Highly recommended.
Plugins
Okay, we use a lot of plugins. I’m going to make this a bullet list. Just pretend it’s a PowerPoint presentation. Er, on second though, don’t.
acts_as_cached
Already mentioned further up, we use memcached to cache many database queries. This plugin supports model caching, session caching, and fragment caching out of the box. A simply memcached.yml is added to our config/ directory and we can forget about it. The README file provides a wealth of common idioms and a mailing list keeps patches (and bug reports) flowing. Essential.
query_trace
Also essential, times two. This plugin attaches a short backtrace to every SQL query in your log files. The first time I heard this I thought, ‘so what?’ Well, it’s a big deal. Suddenly you know exactly what is going on with your ActiveRecord code—you know the exact line number from which queries are being spawned. When you’re trying to cache everything using memcached, this goes a long way in helping you sort out what’s what.
exception_notification
Again, essential. E-mails us whenever an exception is raised on the site. Some days I just gather up the exceptions in my Inbox and bang away on those bugs for an hour or two. Then, no more e-mails. It’s very gratifying. Best part is, you can control whether certain exceptions show a 500 or a 404, and you can even set the prefix of the e-mails you receive. For instance, I can set the e-mail prefixes then setup mailbox filters to have all the e-mails prefixed with [CHOW] go to my Inbox and all the e-mails prefixed with [CHOWHOUND] go into my trash can. Very slick.
acts_as_textiled
The first ‘official’ plugin extracted from our work, acts_as_textiled lets us forget about rendering Textile. Instead of having to ask ‘should I render Textile?’ the question becomes ‘should I not render Textile?’ If a story description uses Textile, we always want it rendered—except in special circumstances. It’s nice to not have to use the textile helper all over our app and instead focus on things that matter. Like pastels.
acts_as_solr
This is a bit of a white lie. We’re currently using a plugin PJ rolled called ‘acts_as_indexed,’ but he is in the process of transferring our stuffs over to acts_as_solr. It’s a fine piece of work and written by people who know Lucene (and solr) inside and out. One of those dudes even wrote a book, I hear.
debug_view_helpers
This is a real life saver. If you’ve ever used Smarty, you know how great that ‘debug’ window is that pops up. There’s no ambiguity for your CSS people: all the available variables are shown right there in a pop-up window. We installed this plugin and set the ‘debug’ link to appear a) in development mode b) if you’re on the VPN. That means, even in production mode, authorized elite personnel can always see the variables available to the view. So awesome for debugging. (Plus it means I don’t have to talk to our CSS guy, Todd, so much. He is weird.)
has_many_polymorphs
Evan Weaver’s crazy plugin lets us forget about all the black magic we learned from Josh Susser. Little o’ this:
class Tag < ActiveRecord::Base has_many_polymorphs :tagged_things, :from => [:posts, :files, :tags] end
Yup. Very nice. Also lets you do Tag.find(:all, :include => :tagged_things) and fetches the result in one query. But who cares, you’re caching everything anyway, right?
request_routing
Hey, check out this code:
map.connect '', :controller => 'mobile', :conditions => { :subdomain => 'm' }
Can you believe that’s not in core? Me neither. It’s great, and thanks to the request_routing plugin we’re able to use it for Chow’s mobile site. Plus, Dan Webb’s blog is hot. There. I said it.
redbox
You just have to see it for yourself. Real nice code which lets you pull off that whole ‘lightbox dialog’ thing. We’re using it for the ‘E-mail to a Friend’ links. The less Javascript we have to write, the better.
unicode_hacks
Right now, Unicode seems to fall down when you need to pattern match against it or do any sort of string manipulation. Lucky for us we just do input and output. Until the new Rails hits the streets, we rely on the unicode_hacks plugin to get those crazy foreign characters in and out of our database correctly.
browser_filters
Safari crashing randomly? We (correctly) suspected Unicode. This Super Official Rails Plugin solved our problems and may solve yours. Also provides a few more fixes and tweaks.
composite_migrations
Yes, we’re crazy enough to use composite primary keys. That’s just the way some of us were raised. This home rolled plugin allows us to create the dastardly fellows in a migration so that we may use the composite primary key gem freely and openly in our code. Hey, we’ve got opinions, too.
Libraries
First and foremost, hpricot is an amazing invention and a huge help. Scraping and parsing HTML/XML isn’t something we think twice about anymore. We use hpricot on more than one XML import feed because it’s just so damn easy. If you’ve never given it a shot, I recommend trying it soon.
Both Dr Nic’s Magic Models and Camping are used by us to prototype all sorts of ideas and internal tools. Some of our top secret monitoring tools run using a combination of the two. Being fluent in Camping, and knowing some tricks to get it working with Magic Models, is a must.
RFuzz, available as a standard Ruby gem, is a library which makes it trivial to test web sites. We run periodic RFuzz tests against our live sites to make sure they’re alive, bullet proof, and speedy. The tests run just like unit tests and help us feel that much better about our babies. During the big security fiasco RFuzz was instrumental, and since I’ve fallen in love.
When it comes to testing, nothing gives me more pleasure than color. Thanks to Pat Eyler, the redgreen gem makes all those little repetitive dots that much more bearable.
Use autotest. It takes your mind off the testing and lets you focus on the tests.
FasterCSV is a gem you can get from the RubyGems stronghold. One of our data feeds is delivered as Excel, which is basically completely useless. We export it to CSV then import it into our database with FasterCSV, which can nail about 5000 records in 2 seconds. Awesome.
Mocha is a library for stubbing and mocking tests. Because of it, I’ve slowly been moving over to a fixture-less and speedy state of mind. There’s all sorts of information out there on using Mocha (as well as a mailing list), so dive right in.
First made known to me by technoweenie, Piston is an incredible tool for managing Rails plugins. We had troubles when deploying with svn:externals: our server would try to make too many connections to the external SVN server too quickly. As a result, the connections would die and the deploy would fail. Piston solved this issue: we can keep plugins in our local repository and sync them up with their remote repository whenever we want. So far it’s been working out wonderfully, and so easy! If you haven’t started yet, get on the Piston bandwagon immediately.
Editing
Sorry, I admit it: I’m not a TextMate guy. Sure, I’m writing this post in TextMate, but I still prefer vim for coding. I know there’s at least one duder out there who can side with me. For that one guy (you know who you are), here’re a few classy vim links: the wiki page, the gem, the Rails plugin, and the html-macros plugin. All essential.
Outliers
Like everyone else, we use Subversion and Trac to manage our source code and tickets. We also use Marshmallow and a polling Ruby process to notify us of changes to Subversion. It’s helpful to see the commits in Campfire as they’re always there, whether you are or not.
We recently started using Crazy Egg to check out clicks on our site and wow wow wow. Everyone has already talked about it, but try it out. F’real. So easy, and it gives you an entirely new perspective on your site.
Hammers and Tape
So that’s my toolbox. Maybe I missed a few screws or rulers, sure, but you get the general idea. Have any really great sheets of sandpaper you want to share? Hit me in the comments.
I think you caught pretty much everything we use (cept maybe donthurtme lighttpd sigh), really awesome list – now i’m gonna have to set aside a few days next week to play with all the stuff you named that I’m NOT already using – thanks!
Awesome definitely is a good word – thanks :)
I’ve had your feed in my “daily” list since you guys started this blog. I am continually amazed at the volume of useful information you provide. This is the best (only?) list I have seen that actually describes all of the stuff that goes into a real app. This glimpse into your world truly awesome. Thanks for Sharing!
One thing I forgot to mention the first time around is Juggernaut: http://juggernaut.rubyforge.org/ Most of the stuff I do includes some ‘literally live’ concept, and Juggernaut is invaluable for anything that is lie between the server and the user.
Really helpful stuff. Thanks!
Have you looked at searchable as an alternative to acts_as_solr?
Wow, once again I am amazed by an amazingly useful and informative post from you guys. I would type more, but I had to open so many tabs (to view all that sweet stuff), that I can hardly see this textarea… Thanks a ton!
Good stuff. Very helpful and informative.
debug_view_helpers
This sounds awesome if it is anything like SMARTY’s popup. Not having a variable debug window always kinda scared me about working on rails from a front-end standpoint.
“and instead focus on things that matter. Like pastels.”
Hilarious, sir.
(vim for the win !)
Yes! It’s Dylan! The other vim dude!
I agree on piston, that is awesome
Wow…Equally overwhelming and exciting. Great stuff.
Very useful info and a great blog – thanks!
Nice article, it’s good to hear how you can implement a high traffic site such as chowhound. On a slightly related note, did you implement any rails page/action caching or just rely on memcache?
Great list, thanks!
Chris, thanks for the great writeup. It’s helpful to see what’s in use on a production site.
What is the traffic on Chow.com?
nice.
I love your use of pink.
Thanks for posting this!
thank-you!!! awesome.. a well sharpened bunch of tools..
Woot! Another Vim user!!
Great list and excellent write up – many thanks!
This list is hot! Thanks for a few new links. How does the Lucene plugin you mentioned compare to acts_as_ferret? I’ll have to check it out.
Excellent thanks for this. Out of curiosity how did you end up converting the excel feed – did you manage it to automate it?
that’s one nice list, for sure. Duly stowed.
I’m no hardcare rails developer, but I’m learning and I’m vim all the way. Thanks for article.
Thanks! for the nice post!
I’m just learning Ruby/Rails. This is a very helpful list. Nice to see what stuff is actually being used out there. Thanx!
Wondering what your using for your backup tools.
I’m glad to see more and more people using the acts_as_solr plugin even though it’s on its early stages. Solr is a great engine and we’re glad to make it available to Rails users through the acts_as_solr plugin.
If you’d like to learn more about integrating Rails with a robust full-text search using Solr and acts_as_solr, we’re trying to get a 1 hour session spot at the Rails Camp on Nov. 9th in San Jose, CA
Just to mention, the new release of the acts_as_solr plugin will be available in a few days, with bug fixes and couple new features.
Cool! Very nice!
There are at least three VIM dudes. I use it for anything except Java development. It is a solid Ruby “IDE,” if one is willing to write a few key mappings to run script, launch test suites, etc.
Nice article.
Nice Article!
Thanks,very nice.
Blog post of the year!
I also would like to see here Cerberus Continuous Integration tool. http://cerberus.rubyforge.org
I found it very useful for my 4-person project. Very useful! And I recommend it any other developer.
Hello friends! i new on your forum! see ya:))
The Ultimate Search Engine On Music Video & lyrics All In One The Hottest Music On Earth good tools while you working listen to:::::
http://www.oketube.com
Holy sweet Christ this is amazing; now if only there were blog posts out there like this . . . for us PHP heathens
This whole article was fabricated just so you could use that picture wasnt it? =]
Great stuff!
What we use really often:
- will_paginate - acts_as_ferret - dynamic session expiration - haml - rspec & rspec on rails - ...
Those are excellent plugins!
could you share your .vimrc with us?
Chime in.