Rails 4.1 Performance Fundamentals

Speed up your Ruby on Rails 4.1 (and 4.0 and 3.2) applications. This course covers profiling techniques; making fewer, faster, database queries; Russian Doll caching; Turbolinks and more.
Course info
Rating
(76)
Level
Intermediate
Updated
Jul 4, 2014
Duration
4h 20m
Table of contents
Introduction
Ruby 2.1
Rails Performance and the Database
Browser Caching
Fragment Caching
Russian Doll Caching
Turbolinks and pjax
Conclusion
Description
Course info
Rating
(76)
Level
Intermediate
Updated
Jul 4, 2014
Duration
4h 20m
Description

Speed up your Ruby on Rails 4.1 applications. With the help of some gems, all techniques in this course can also be used in Rails 3.2 apps. This course teaches pragmatic, Rails-specific techniques to profile performance, find and fix slow database queries, get alerted automatically whenever you create an N+1 query, and simulate latency and low bandwidth. You'll also learn to take advantage of the browser's cache with ETags or time-based expiration, set up Memcached for server-side caching, speed up view rendering with fragment caching, cache nested fragments with Russian Doll caching, and use Turbolinks and pjax to give a multi-page app the responsiveness of a single-page app.

About the author
About the author

Brian Morearty is a Ruby on Rails consultant and an entrepreneur. He is the former Tech Lead on the QuickBooks UI at Intuit, and was a Principal Member of Technical Staff at Oracle. He has a Computer Science degree from UC Berkeley. He is not Sherlock Holmes' evil genius arch-enemy.

Section Introduction Transcripts
Section Introduction Transcripts

Introduction
You're a developer on a Rails team. Your boss comes to the team and says, "The app is too slow. "Users are unhappy, and they're dropping off. " What are you going do to? Do you, A - blame the developers who architected the app, but no longer work at the company. B - tell your boss that you're late for a very important ping pong game, and you'll talk later. Or C - tell your boss that you have to rewrite the whole thing in Java. I'm Brian Morearty, and this is Pluralsight's course on Rails 4. 1 Performance Fundamentals. The only prerequisite for this course is knowing how to write web apps in Ruby on Rails. And obviously, the answer to the question I just asked is "None of the above. " In this course I will show you a bunch of techniques for profiling your Rails app, and a bunch more techniques for speeding it up. Each technique stands on its own, and you can pick and choose which ones you think will work best for the apps you work on. If you were to apply most or all of these techniques to a Rails app, you could make that app blazing fast. The course covers some old techniques that have been around for years, and goes all the way up to the newest techniques that were introduced in Rails 4, such a Russion doll caching and turbolinks. However, all the techniques I describe can be used in Rails 3. 2 apps if you incorporate the right gems. In cases where a given technique requires a gem for Rails 3. 2, I will mention that.

Ruby 2.1
How would you like to get a speed boost in you Rails app without modifying the code at all and without upgrading your hardware. In fact, how would you like to be an all-powerful wizard with the forces of nature at your beck and call? Able to cause volcanoes to erupt and the sun to move backwards in the sky? It turns out can simply by using a newer version of Ruby. I'm Brian Morearty and module two of Rails 4. 1 Performance Fundamentals. In this module we will look at Ruby 2. 1 and higher.

Rails Performance and the Database
When you're tuning the server side of a slow Rails application, you will most likely find that the place where most of your performance problems occur is in the interaction with the database. That is why, in this Module, you will learn all about how to speed up those interactions by reducing the number of round trips to the database, and the length of time each round trip takes, because that will speed up your Rails App. And in this Module, I'm going to demonstrate a lot of techniques for diagnosing database-related problems in a Rails app, as well as a whole bunch of techniques for fixing them. I'm Brian Morearty, and this is Module Three of Rails 4. 1 Performance Fundamentals. There are two main things you can do to make your database interaction faster. The first is make fewer queries, and the second is make faster queries. In my experience, I've found that although making faster queries does make a big difference, making fewer queries has a bigger effect on performance improvement than faster queries in most applications. But we will cover both of them here, and you will actually see cases in this Module where making faster queries has a huge impact on the performance of the application. These are the Models in the I Teach U sample app that I showed you in the last Module. Each Teacher has many courses, and each course belongs to one Teacher. Enrollment is a join table between Course and Student, so each Course has many Enrollments and each Student has many Enrollments. And Enrollment belongs to a Course and belongs to a Student, but also, each Course has many Students through Enrollment and each Student has many Courses through Enrollment. That's all. It's a fairly simple app, but as I mentioned in the last Module, I purposely wrote it without performance optimizations so that it will have a lot of performance problems, and I'll show you how to diagnose them and fix them in this Module.

Conclusion
Congratulations! You've made it to the end of Rails 4. 1 Performance Fundamentals. I'm Brian Morearty and in this conclusion, I'm going to do two things. First, I'm going to quickly recap the things that we covered in the course, but the second thing I'm going to do is show you where you can learn more about Rails performance if you're interested in diving in even deeper. First, we talked about why performance and it really boils down to three things, happy users, happy you and more money for you because when the users are happy, they're going to be more likely to use your application and hopefully you make money on your application. You also get higher SEO rankings when your application is fast because Google is more likely to rank your page higher and also with mobile users, they have pretty high network latency so a high performing app helps especially with them.