
I just finished with Crafting Rails Applications by José Valim. The book claims to teach Expert Practices for Everyday Rails Development. I didn’t find it to be exactly that, however I did enjoy it and I learned a ton.
The Good
The book flows pretty well. Each chapter contains a challenge or set of related challenges and it’s pretty easy to follow along with the code. Each example contains automated tests, and he creates a gem for almost each solution, so that it is easy to see how to modularize things.
The coverage of Rails internals is really enlightening. Sometimes it can be a bit dry, but you’ll learn quite a few things about Renderers, Responders, Engines, Railties, Routing, Rack, Instruments, and more.
The book also contains a wide range of technology topics. José doesn’t just utilize Rails & ActiveRecord. Other examples include MongoMapper, Redis, and Sinatra.
The Bad
Even though each of the examples contains unit tests, they are written in a style that I find to be problematic in real systems. The concise nature of the tests is probably an artifact of being printed, but most of the testing examples utilize few test classes with many assertions per test method.
In addition, though he “writes” the tests before implementation, this actually hurts understandability in some cases. The reason is most of the tests read as if he already knew the implementation and knew exactly how to test it. But it isn’t apparent to the reader.
I tend to prefer RSpec with 1 assertion per test method and many fine-grained methods that test various behaviors in each context my system is in. The book’s Test::Unit style wasn’t something I’d suggest as a good way to test real applications.
The Bottom Line
Ultimately I think the book is excellent, and certainly gives plenty of information about Rails 3 internals. I think newcomers would probably be lost, but if you’re past the newbie stage with Rails then this book is recommended.












In this graph you can see the overall HTTP Throughput (higher is better) against the Heroku backlog depth. The more dynos you have, the quicker your backlog is cleared out, equating to more throughput. You can clearly see that we are now hitting a limit on the throughput we can handle because the queue depth is increasing. We might choose to optimize the site or add another dyno to squeeze some more perf out of this.
Also in the image if you were to mouseover on the queue stacks on the website, you’d see that my peak queue depth was 29. That’s pretty high, and you can definitely see a cap in the total # of requests that we can serve.
In the end, I’m able to pretty reliably say that we can handle a 10k request spike when running on 2 dynos. I’d suggest more dynos if the client wanted to handle more than that.
Gotta love tools that make investigation like this easy. Props to Heroku & New Relic.