Ruby on Rails Concepts

Rails framework and application performance concepts explained in depth, one at a time.

Sort

Database & ActiveRecord

5

Zero-Downtime Schema Migrations at Scale

A migration that runs in 40ms in dev can hold an ACCESS EXCLUSIVE lock on a production table for minutes — this concept covers exactly which DDL locks what, how strong_migrations catches it before it ships, and the multi-deploy pattern for changes that are unsafe no matter how you write them.

6

Multiple Databases, Read Replicas, and Horizontal Sharding in Rails

A read replica offloads query load but does nothing for write throughput or storage on the primary — sharding is the much bigger, much harder step for when the primary itself is the bottleneck. Rails 6+ gives you connects_to, connected_to, and automatic DatabaseSelector/ShardSelector middleware for both, but the 2-second staleness window and cross-shard joins each carry real, easy-to-miss failure modes.

10

Postgres Indexing Through Rails Migrations

Which indexes a Rails schema actually needs, why composite index column order decides everything, and how to confirm from a Rails console that Postgres is really using the index you added.

12

Eager Loading Strategy and Bulk Database Operations

includes isn't one strategy, it's a choice between preload and eager_load — and nested eager loading can multiply instantiated objects until it's slower than the N+1 it replaced. Plus: aggregate in SQL, and activerecord-import for bulk writes.

16

Connection Pooling and pgbouncer Math

The processes × threads × hosts arithmetic your database pool has to fit under, why deploy-time overlap is the real risk, and how pgbouncer's pool size means something different.

19

N+1 Queries and Query Methods in Model Instance Methods

The most common source of hidden N+1s isn't a missing includes — it's an ActiveRecord query method quietly living inside an instance method.

Application Servers & Infra

Caching

Background Jobs

Observability

Front-end & Network

API Design

Application Architecture

Security