Blog

Engineering Notes

Long-form posts on Rails internals, PostgreSQL at scale, distributed systems, and AI-assisted engineering.

EN PT
ml

You don't understand Machine Learning until you implement it from scratch

Calling sklearn.fit() isn't understanding. Building a perceptron, logistic regression and a net that solves XOR in Ruby is. ML is algebra and optimization — not magic.

· 5 min read
ml

Gradient descent, visually explained

Cost function is a surface. Derivative is slope. θ = θ − α·∇J(θ). Every neural net you've ever heard of is this rule, repeated.

· 5 min read
infra

epoll and io_uring, explained visually

Blocking IO → select → poll → epoll → io_uring. Every step exists because the previous one stalled. Async isn't a language feature, it's a kernel feature.

· 5 min read
infra

How the Linux kernel actually receives an HTTP request

NIC → driver → IRQ → softirq → IP → TCP → socket buffer → accept queue → Puma. Your framework is the last 5% of the request. The rest is kernel.

· 5 min read
distributed

The \"exactly once\" myth

Exactly-once doesn't exist on the network. What exists is at-least-once plus idempotency. Stop chasing a marketing myth — design for reality and sleep at night.

· 4 min read
distributed

How to avoid retry storms in background jobs

External API goes down. 100k Sidekiq jobs decide to retry at the same time. Jitter, circuit breaker, DLQ — retry isn't a fix, it's a deferral strategy.

· 5 min read
distributed

Idempotency in real systems

At-least-once is reality. A unique constraint is the only real guarantee. Idempotency-Key, dedupe tables — survival in distributed systems.

· 4 min read
postgres

Lock contention: the silent killer in PostgreSQL

A 10ms migration that freezes production for 40 minutes. ALTER TABLE grabbing ACCESS EXCLUSIVE. pg_locks + pg_stat_activity. Locks are invisible — until they aren't.

· 5 min read
postgres

What VACUUM actually does in PostgreSQL

MVCC, dead tuples, bloat, autovacuum, transaction wraparound. VACUUM isn't cleanup — it's how Postgres works. Ignoring it is how you wake up at 3am.

· 5 min read
postgres

EXPLAIN ANALYZE should be mandatory

Junior runs the query. Senior runs the query plan. Seq Scan, Index Scan, Bitmap Heap, estimated vs actual, BUFFERS — reading the plan isn't optional, it's the job.

· 5 min read
rails

You DON'T understand Rails until you understand the full Request cycle

Rails isn't magic. Rails is Rack, TCP, threads, middleware, SQL and Ruby objects on the heap. Understand what happens before and after your controller.

· 5 min read
architecture

Refactoring a monolith without blowing up production

Microservices aren't the answer. Refactoring a monolith is an art — strangler fig, feature flags, stepwise schema migration. What nobody tells you about the process.

· 5 min read
performance

How to identify a performance bottleneck in minutes

Every slow app has ONE dominant bottleneck. Guessing doesn't cut it. Learn the suspect hierarchy, the right tools and the workflow that goes straight to the cause.

· 5 min read
performance

Debugging memory leaks in Ruby without crying

Ruby has a GC. So classic leaks don't really exist. What does exist is bloat — and knowing the difference is what separates senior from junior here.

· 4 min read
ruby

Writing a simple DSL from scratch in Ruby

Rails, RSpec, Sidekiq, Devise — every famous gem is a DSL. And none of them is magic. They're simple metaprogramming tricks you can replicate in an afternoon.

· 4 min read
rails

How ActiveRecord builds SQL under the hood

You're not building SQL. You're building a tree. Understand Arel, bind parameters, lazy evaluation and the real difference between includes, preload and eager_load.

· 4 min read
ruby

Ancestors chain: how Ruby actually resolves methods

The favorite interview question to separate a Rubyist from someone who just writes Ruby. Include, prepend, singleton classes — every doubt has the same answer.

· 4 min read
ruby

How Ruby resolves methods internally

When you call user.name, Ruby performs a ritual. Method lookup, inline cache, method_missing, singleton classes — the real mechanics behind a simple call.

· 4 min read
ruby

GIL: the lock every Rubyist needs to understand

Ruby has no real parallelism because of the GIL — a half-truth said with confidence. Understand the GVL for real, when threads help and when they become traps.

· 4 min read
ruby

Understanding Ruby's runtime (not just the language)

Most know the language. Almost none know the runtime. YARV, heap, GC, GVL, inline cache — where engineering lives and where production bugs are born.

· 4 min read