All Stories

Zero-Downtime Database Migrations in Rails: Guarding Production with Strong Migrations

The migration that nearly took us down wasn’t a clever one. It was add_index :orders, :customer_id, run at 2pm against a table with 40 million rows. Postgres holds a SHARE...

ActiveRecord Validations vs. Database Constraints: Finding the Optimal Balance

validates_uniqueness_of is not a data-integrity mechanism. It is a user-experience mechanism, and treating it as anything more is how you end up with duplicate invoices. The failure mode is embarrassingly...

Building a Replicated State Machine in Go using the Raft Consensus Algorithm

Every gateway node in our fleet needs the same piece of truth at boot: the shard-to-node mapping, the config revision, the list of revoked keys. Before Raft, that truth lived...

Go `sync.Pool` Mechanics: Minimizing Allocation Pressure and GC Interactions

Our request marshaling path allocated a handful of small buffers per request – fine at 1k req/s, a garbage problem at 20k. sync.Pool looked like the obvious fix, and it...

Building an API Gateway Rate Limiter in Go using the Token Bucket Algorithm

Our gateway terminates traffic for public APIs, and the first thing every unauthenticated request hits is a per-API-key limiter. With 50k active keys and a sustained 100k req/s, the limiting...

Optimizing Struct Layouts in Go to Reduce Memory Padding and Cache Misses

Eight bytes per struct. That is what a careless field order cost us in a 1M-record in-memory index we cache in a service that answers every lookup request. Eight bytes...