By 2024, I was working on apps that had moved beyond small MVPs. Some of them were getting thousands of daily users, and the old ways of coding weren’t enough. I had to dive deep into performance tuning — both on the backend (Rails) and frontend (React).
# Bad
@users = User.all
@users.each do |u|
puts u.posts.count
end
# Good
@users = User.includes(:posts)
@users.each do |u|
puts u.posts.size
end
Controller
@posts = Rails.cache.fetch("recent_posts", expires_in: 10.minutes) do
Post.order(created_at: :desc).limit(20).to_a
end
Heavy tasks (emails, API calls, reports) → moved to Sidekiq + Redis.
add_index :users, :email, unique: true
// Use React.memo
const TodoItem = React.memo(({ todo }) => {
return {todo.text} ;
});
const Dashboard = React.lazy(() => import("./Dashboard"));
import { FixedSizeList } from "react-window";
{({ index, style }) => Row {index}}
react-window:
Measure before fixing → Tools like rack-mini-profiler, NewRelic, and Chrome DevTools were critical.
Backend bottlenecks affect frontend → If APIs are slow, React can’t save you.
Performance is never “done” → It’s an ongoing process.