Blog
· AI · 10 min read
Mixture-of-Experts: sparse models, routing and the cost of balance
How MoE layers route each token to a few experts: top-k gating, why routers collapse and how load-balancing losses and bias terms prevent it, expert capacity and dropped tokens, all-to-all communication, and total versus active parameters.
· AI · 24 min read
Inside an AI coding agent: loops, attention, context and orchestration
How a coding agent keeps working on a task: the agent loop, why attention dilutes as context grows, context engineering and compaction, the KV cache, keeping long runs on track, and orchestrating roles as a DAG.
· AI · 10 min read
Speculative decoding: faster generation with an exact proof
Why decoding is bound by memory bandwidth, how a draft model's guesses are verified in one pass, the rejection-sampling proof that the output is exactly the large model's, the expected speedup, and Medusa, EAGLE and tree verification.
· AI · 23 min read
Retrieval-Augmented Generation, from first principles
How RAG actually works: chunking, embeddings and the geometry of similarity, HNSW, hybrid search with BM25 and RRF, reranking, prompt assembly, evaluation, and the ways it fails.
· AI · 12 min read
FlashAttention: making attention IO-aware
Why attention is limited by memory bandwidth, not compute: the GPU memory hierarchy, tiling, the online softmax that makes tiling exact, recomputation in the backward pass, and what FlashAttention-2 and -3 changed.
· AI · 9 min read
From RLHF to DPO: the maths of preference training
Bradley–Terry reward models, PPO with a KL penalty, the closed-form optimum that lets DPO drop the reward model, reward hacking, and GRPO with verifiable rewards for reasoning models.
· AI · 12 min read
Quantization, done properly: from FP8 to GPTQ and AWQ
Number formats from FP32 to INT4, scales and group sizes, why outlier activations break naive quantization, and the three methods that fixed it: SmoothQuant, GPTQ's second-order error correction, and AWQ's activation-aware scaling.
· Distributed Systems · 9 min read
Inside Kafka: partitions, consumer groups and exactly-once
Kafka as a partitioned, replicated log: keys and ordering, why sequential I/O makes it fast, retention and compaction, the ISR and high watermark, consumer groups and rebalances, and how idempotent producers and transactions give exactly-once.
· Databases · 13 min read
Transaction isolation: what your database actually promises
The SQL isolation levels and why their names mislead, MVCC and snapshots, lost updates under Read Committed, snapshot isolation and write skew, serializable snapshot isolation, and the production cost of long transactions.
· Backend · 11 min read
Microservices vs the modular monolith: what you actually buy
What a service boundary costs and buys: partial failure and ambiguous timeouts, how availability and tail latency compound across hops, data ownership, bounded contexts and Conway’s law, and when a modular monolith is the better trade.
· Databases · 11 min read
Zero-downtime schema migrations in Postgres
How a quick ALTER TABLE queues every query behind it, the lock levels that matter, lock_timeout and retries, which changes rewrite or scan a table, NOT VALID constraints and concurrent indexes, batched backfills, and expand–contract deploys.
· Backend · 9 min read
API evolution: changing interfaces without breaking clients
Backward and forward compatibility and why requests and responses differ, protobuf’s field-number rules, tolerant JSON readers, REST, gRPC and GraphQL, expand-migrate-contract, versioning and deprecation, and contract testing.
· DevOps · 8 min read
Distributed tracing: following one request through many services
Traces and spans, W3C Trace Context and how context propagates across processes and queues, reading a waterfall and its critical path, OpenTelemetry, head versus tail sampling, and the places traces quietly break.
· Frontend · 11 min read
Why React re-renders: reconciliation, keys, memo and signals
What a render is and why most are cheap, the three reasons a component renders, how React decides what to keep, why keys are identity, structural fixes before memo, context and stores, and how signals take a different path.
· Distributed Systems · 13 min read
Paxos vs Raft, and why consensus is hard
What consensus must guarantee and the FLP impossibility result, quorum intersection, Paxos and Multi-Paxos, Raft's elections and log repair, membership changes, and what linearizability actually promises clients.
· Distributed Systems · 8 min read
Sagas and the outbox pattern: transactions without distributed transactions
Why two-phase commit rarely crosses service boundaries, sagas and compensating transactions, choreography versus orchestration, the isolation sagas give up, the dual-write problem, the transactional outbox, and idempotent consumers.
· Databases · 13 min read
How LSM-trees power modern databases
The storage engine behind RocksDB and Cassandra: memtables and SSTables, leveled versus tiered compaction, write, read and space amplification, the maths of Bloom filters, and why deletes are the hardest operation.
· Backend · 10 min read
Retries, timeouts and circuit breakers: how services fail together
How retries amplify small failures into outages: timeouts and deadline propagation, exponential backoff and jitter, retry budgets, idempotency, circuit breakers, metastable failures, load shedding and hedged requests.
· DevOps · 9 min read
SLOs and error budgets: turning reliability into a decision
SLIs, SLOs and SLAs, choosing what to measure and what target to set, error budgets and budget policies, multiwindow burn-rate alerting, latency objectives, and the ways SLO programmes go wrong.
· Backend · 11 min read
Caching without lying: invalidation, stampedes and cold starts
Cache-aside, read-through and write-through, the invalidation race delete-on-write leaves open, leases and change-data-capture invalidation, cache stampedes and XFetch, and what happens when the cache becomes load-bearing.
· DevOps · 11 min read
Infrastructure as code: state, drift and safe applies
How Terraform decides what to change, what the state file really is, reading a plan and spotting replacements, renaming without destroying, drift, splitting state to limit blast radius, and a workflow that makes applies uneventful.
· Frontend · 10 min read
Rendering on the web: CSR, SSR, streaming and Server Components
When content appears versus when the page responds, client-side and server-side rendering, the hidden cost of hydration, static generation, streaming with Suspense, React Server Components, islands and resumability, and choosing per route.
· DevOps · 10 min read
Kubernetes requests and limits: throttling, OOM kills and QoS
What CPU and memory requests and limits actually do, why CFS quotas throttle services that look idle, OOM kills and node-pressure eviction, QoS classes, runtimes that misread their limits, and how to choose the numbers.
· Backend · 10 min read
Authentication for services: sessions, JWTs and OAuth
Reference and self-contained tokens, server-side sessions, verifying JWTs properly and the revocation problem, refresh token rotation, OAuth 2.0 with PKCE and OpenID Connect, tokens in the browser, service identity, and object-level authorisation.
· Frontend · 10 min read
The browser rendering pipeline: layout, paint, compositing and INP
The frame budget and the event loop, style, layout, paint and composite, forced synchronous layout, the compositor thread, long tasks and Interaction to Next Paint, yielding to the browser, and measuring responsiveness in the field.
· Distributed Systems · 11 min read
CRDTs and collaborative editing
Why naive edit merging diverges, how operational transformation fixes it and why it is hard, state-based and op-based CRDTs, sequence CRDTs like RGA and YATA, the interleaving problem, tombstones, and how real products sync.
· Distributed Systems · 10 min read
Going multi-region: latency, failover and the data problem
When running in several regions is worth it, what the speed of light costs, RPO and RTO, active-passive failover and split brain, partitioned and consensus-based active-active, read-your-writes across regions, and capacity for failover.
· Databases · 9 min read
How database indexes really work
B-tree layout and why lookups take a few page reads, seek, scan and fetch, when the planner ignores an index, composite index column order, covering, partial and expression indexes, clustered tables, and what each index costs on writes.
· DevOps · 9 min read
Progressive delivery: canaries, blue-green and feature flags
Why changes cause most outages, rolling, blue-green and canary deploys, running canaries with enough traffic and the right baseline, automated canary analysis, feature flags and flag debt, and the changes no rollout can make safe.
· Backend · 12 min read
Queueing for engineers: Little’s law, utilisation and tail latency
Little’s law, why latency explodes as utilisation nears 100%, Kingman’s formula and the cost of variability, shared queues and the power of two choices, sizing connection pools, overload, and planning headroom.
· Backend · 11 min read
HTTP/1.1, HTTP/2 and HTTP/3: connections, multiplexing and head-of-line blocking
What a connection costs in round trips, why HTTP/1.1 needed six connections, how HTTP/2 multiplexes streams, why TCP still blocks them, what QUIC changes, and what it all means behind a load balancer, including the keep-alive 502.
· Databases · 12 min read
How the query planner picks a join
From SQL to a plan tree, nested loop, hash and merge joins and when each wins, row estimates and the independence assumption, join order, reading EXPLAIN ANALYZE, generic plans for prepared statements, and fixing a bad plan.
· Backend · 9 min read
Rate limiting: token buckets, sliding windows and global limits
The token bucket and its burst and rate guarantees, the leaky bucket and GCRA, fixed, sliding-log and sliding-counter windows, enforcing limits across a fleet, choosing keys and costs, and telling clients with 429 and Retry-After.