Slow Rails applications rarely have one universal fix. The bottleneck may be repeated Active Record queries, a PostgreSQL plan that no longer fits the data, expensive Ruby work, overloaded background jobs, excessive allocations, or time spent in an external service. Effective Rails performance optimization starts by measuring the affected workload and locating where the time or capacity is actually going.
This page collects my practical Ruby on Rails performance articles and case studies in one place. The lists below are generated from content tagged with both Ruby on Rails and Performance, so newly published material appears here automatically.
What these Rails performance resources cover
The technical guides explain how to investigate specific problems, including N+1 queries, PostgreSQL query plans, counting large datasets, and profiling Ruby call stacks. The case studies document changes made in real codebases, with the original bottleneck, implementation approach, validation method, and upstream source where the work is public.
Use the guides when you are investigating the problem yourself. Use the case studies to see how similar issues were measured and corrected in existing applications. Results from one workload should not be treated as a promise for another: data shape, traffic, infrastructure, and application behavior all affect the outcome.
A reliable optimization process is straightforward even when the diagnosis is not: define one user-visible symptom, capture a comparable baseline, profile the complete path, implement the smallest well-supported change, and measure again. Query count, request latency, database execution time, queue latency, throughput, allocations, and memory are useful metrics only when they match the problem being solved.
Technical writing
Rails performance guides
Using speedscope.app to Profile Ruby and Rails
A request that takes 900 ms tells us that something is slow, but not where the time went. A call-stack profiler supplies the missing data, and speedscope turns that data into an …
How to Fix N+1 Queries in Rails: Patterns From Six Real Pull Requests
Five N+1 fix patterns with before/after code and benchmarked results from merged pull requests in Forem, Discourse, OpenProject, and Gumroad, plus the regression specs that keep them fixed.
How to Add PostgreSQL Index based on Query Plan as a Rails Developer
As Rails developers, we often focus on writing clean, efficient Ruby code. However, as the application grows optimizing database performance is equally crucial for creating …
Understanding The Output of EXPLAIN As a Rails Developer
Rails Active Record is a powerful ORM that simplifies database operations, but complex queries can sometimes lead to performance issues. We can use EXPLAIN to find out details …
Cheat Sheet for Rails + PostgreSQL Count Performance
The convenience and power of Active Record allows you to interact with your database in a more Ruby-like way, making it easier to write efficient and readable code. However, as …
Using ActiveRecord Strict Loading to explicitly prevent N+1
Active Record strict loading is an awesome feature in Rails that can significantly improve your application’s performance by preventing N+1 queries. In the past days before …
Measured work
Rails performance case studies
Reducing role queries across Forem’s role-heavy paths
An open source Rails performance optimization that made role checks association-aware across Forem’s admin member list, CSV export, async user payload, and reCAPTCHA service.
Making Forem’s cold analytics backfill 10× faster
An open source Rails performance optimization that replaced per-article analytics recomputation with bulk SQL aggregation, cutting median backfill time by 90.1%.
Removing per-product queries from Gumroad’s Products API
A co-authored open source Rails performance fix that batch-loaded product serialization data, cutting mean response time by 40.4% and SQL events by 77.7%.
Reducing a Rails dashboard load time from over 2 seconds to under 200 ms
An anonymous Rails SaaS case study covering a greater than 90% reduction in dashboard load time, lower Sidekiq memory use, faster sitemap processing, and safer external-input handling.
Eliminating 762 repeated queries from OpenProject’s Work Packages API
An open source Rails performance fix that removed repeated type-variant lookups from OpenProject’s Work Packages API and cut median server duration by 55.7%.
Cutting Gumroad Sales API response time in half
An open source Rails performance fix that removed N+1 queries from Gumroad’s sales endpoint while preserving its API response.
Removing an N+1 query from Gumroad’s upsells dashboard
An open source Rails performance fix that halved mean request time for a large catalog by replacing per-product variant counts with one grouped query.
Making Discourse’s admin active-users endpoint 66.5% faster
An open source Rails performance fix that replaced per-user two-factor authentication checks in Discourse’s admin active-users endpoint with two batched queries.