Copy
You're reading the Ruby/Rails performance newsletter by Speedshop.

The Rails Performance Workshop is now available for individuals and for teams.

Are you thinking about milliseconds or seconds?

Hello Rubyists,

Over the holiday, I was doing some year-end financial reviews. One of my favorite voices in personal finance is Ramit Sethi. He has a concept of a "$3 dollar question" - a personal finance question that gets a lot of media coverage or attention, but really matters very little to actual financial well-being. A classic example is worrying about interest rates on savings accounts - even in a high-interest environment, which we haven't had in years, moving checking accounts around to chase the latest interest rate promotions is a good way to waste hours chasing $10 in lifetime returns.

I thought this concept applied quite well to a lot of the questions I get around web application performance. Are you asking a question that will improve your critical performance metrics by a millisecond, or by 3000 milliseconds?

The question is meant to remind you to think about the big picture: what are the web performance goals you have, and how do the questions that you're asking fit into that larger picture?

1. How does this decision impact my customer's experience of my website? Does it improve Largest Contentful Paint or Time to Interactive by a significant amount?
2. Does this decision improve my scalability by decreasing resource consumption (i.e. will it let me run fewer servers for the same load?)
3. Does this decision improve my operational stability by allowing me to handle spikes in traffic without downtime?

If the best possible answer to your question doesn't even begin to impact any of these three questions, why are you even asking the question?

Here are some classic 1 millisecond questions:

1. Which JSON serialization library should I use?
2. Is ActiveRecord or Rails too slow, should I switch to Sequel or Sinatra?
3. Should I use Puma or Unicorn?

Here are some 3000 millisecond questions:

1. Are all of the script tags on my page necessary? Have I added the async attribute everywhere I can?
2. Do I have autoscaling set up and configured to scale based on request queue times?
3. Am I using a CDN, and is that CDN configured properly?
4. Does my application currently have any N+1 loading behavior in production?
5. Does my team understand how ActiveRecord loads data, and how to use it in a performant way?

Often, I find that someone asking a 1 millisecond question doesn't understand the possible upside of the answer. For example, when someone asks about "using the highest performance Ruby application server", I don't think they have a clear answer in their head as to what the possible impact of switching from a "low performance" to a "high performance" server would be. 10% higher requests per second? 20% lower average response times?

So to ask the right questions: estimate what the best possible answer could be, and think about how that would actually impact your application's performance goals. If you can't do that, you don't know if this question is a waste of time or not - you have to learn more before you can even meaningfully ask it.

Here's to asking the right questions in 2021. See you next week.

-Nate
You can share this email with this permalink: https://mailchi.mp/railsspeed/stop-asking-1-millisecond-questions?e=[UNIQID]

Copyright © 2021 Nate Berkopec, All rights reserved.


Want to change how you receive these emails?
You can update your preferences or unsubscribe from this list.