[WIP] Guide to Rails Performance

Flavio Wuensche
2 min readDec 9, 2022

A Doctoliber's guide to investigating (and fixing) React and Rails performance issues while keeping users in mind.

This is a series of articles written and maintained by our Engineering team at Doctolib so most of the investigation processes and tooling will be directly related to our React & Rails tech stack, but not limited to it.

Before getting started, I'd like you to keep two things in mind:

  • (1) Your user's perception of performance is more valuable than any automated report from the most advanced tools. So get the hell up and go talk to your users 😇 (passive-aggressive smile)
  • (2) Premature optimization is the root of all evil.

What are the tools? 🧰

  • Chrome Dev Tools
  • React profiling
  • Rails profiling with flame graphs
  • New Relic
  • Explain & Analyze

How to investigate the slowness? 🐌

First, narrow down to the front-end or back-end.

Most common back-end issues

  • [soon] N+1 queries: a shortlist of recommendations on how to find, fix, and prevent N+1 queries in a Ruby on Rails applications.
  • [WIP] Expensive calculations

Most common front-end issues

  • [WIP] Expensive calculations
  • [WIP] Infinite loops

Most common database issues

  • [WIP] Long-running request
  • [WIP] Missing index
  • [WIP] Erroneous PostgreSQL stats
  • [WIP] Database locking

What are the most common solutions? 🧙🏻‍♂️

  • [WIP] Back-end caching (memoization, Rails cache)
  • [WIP] Front-end caching (useMemo, React Query, localStorage, indexedDb)
  • [WIP] Prefetching data with React Query
  • [WIP] Optimist updates with React Query
  • Call Yan Bonnel: with his non-orthodoxal techniques, Yan Bonnel's contribution to…
Flavio Wuensche

Write about React and Rails. Building an open-source tool to keep track of technical debt on large codebases 🍒 cherrypush.com