/articles
Articles
Long-form notes on Rails, PostgreSQL, distributed systems, performance, and ML from scratch.
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.
mlGradient descent, visually explained
Cost function is a surface. Derivative is slope. θ = θ − α·∇J(θ). Every neural net you've ever heard of is this rule, repeated.
mlepoll 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.
infraHow 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.
infraThe "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.
distributedHow 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.
distributedIdempotency in real systems
At-least-once is reality. A unique constraint is the only real guarantee. Idempotency-Key, dedupe tables — survival in distributed systems.
distributedLock 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.
postgresWhat 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.
postgresEXPLAIN 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.
postgresYou 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.
railsRefactoring 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.
architectureHow 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.
performanceDebugging 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.
performanceWriting 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.
rubyHow 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.
railsAncestors 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.
rubyHow 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.
rubyGIL: 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.
rubyUnderstanding 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.
ruby