Engineering Insights

Where I break down concepts, document control flows, and share production engineering patterns - not tutorials, but understanding.

System Design

Latest post

Caching Layers: Where to Cache and What Can Go Wrong

A request can be cached in the browser, at a CDN, in your app's memory, in Redis, and in the database's own buffer pool. Each layer cuts latency and load, and each one adds a copy that can go stale, leak between users, or refuse to be invalidated. Here's what each layer is good for, how their staleness adds up, and how to invalidate a stack of caches in the right order.

11 min read
  • Cover diagram for “Service Boundaries: How to Know When to Split a Service”

    System Design

    Service Boundaries: How to Know When to Split a Service

    Where you draw a service boundary decides which calls become network calls, which transactions become sagas, and which changes need three teams to coordinate a deploy. Split along the wrong line and you get a distributed monolith. Here's how to measure coupling, the signals that justify a split, the ones that don't, and how to find a boundary before you commit to it.

    11 min

  • Cover diagram for “The Case of the Missing Index: How to Debug Slow Queries”

    Databases

    The Case of the Missing Index: How to Debug Slow Queries

    A slow endpoint usually comes down to one query reading far more rows than it returns. Here's a repeatable way to find that query, reproduce it with the right parameters, read what EXPLAIN ANALYZE is telling you, design the index that fixes it, and confirm the fix, plus how to tell when the problem isn't an index at all.

    11 min

  • Cover diagram for “JSONB Columns: When Your Relational Database Wants to Be NoSQL”

    Databases

    JSONB Columns: When Your Relational Database Wants to Be NoSQL

    A JSONB column lets you store flexible, schemaless data next to your tables, and PostgreSQL can index and query it. It's the right tool for sparse attributes, external payloads, and settings blobs. It's the wrong tool for anything you join on, constrain, or update one field at a time. Here's how JSONB is stored, which indexes actually match which queries, and where the line falls.

    10 min

  • Cover diagram for “Composite Keys vs Surrogate Keys: The Decision That Haunts Your Migrations”

    Databases

    Composite Keys vs Surrogate Keys: The Decision That Haunts Your Migrations

    A primary key is the hardest thing in a schema to change, because every foreign key, index, URL, and cache key copies it. Natural composite keys enforce uniqueness for free but ripple through every child table when they change; surrogate keys stay stable but quietly allow duplicates unless you add the right constraint. Here's how each choice plays out over years of migrations, and which to use where.

    13 min

  • Cover diagram for “When to Denormalize: Breaking the Rules for Performance (and When Not To)”

    Databases

    When to Denormalize: Breaking the Rules for Performance (and When Not To)

    Denormalization trades write complexity for read speed: you store a fact in more than one place so reads don't have to join or aggregate. It's a legitimate tool, but every copy needs a sync mechanism and every sync mechanism can drift. Here's how to tell a real denormalization from a snapshot, the ways copies go stale, and a framework for deciding when the trade is worth it.

    12 min

  • Cover diagram for “Why Your Foreign Keys Might Be Lying to You: Referential Integrity vs Application Logic”

    Databases

    Why Your Foreign Keys Might Be Lying to You: Referential Integrity vs Application Logic

    Checking that a parent row exists in application code feels equivalent to a foreign key constraint. It isn't: the check races with concurrent deletes, every script and service that skips your app skips it too, and even real foreign keys can be disabled, unvalidated, or bypassed by NULLs. Here's where referential integrity actually comes from, and where each approach belongs.

    15 min

  • Cover diagram for “Database Migrations in Production: Schema Changes Without Downtime”

    DevOps & Cloud

    Database Migrations in Production: Schema Changes Without Downtime

    The migration ran in 40 milliseconds and still caused an outage. Production schema changes fail in two ways: the old code can't handle the new schema during a rolling deploy, or a quick ALTER waits on a lock and freezes every query behind it. Here's the expand/contract pattern, the locking traps, and how to change a schema under live traffic.

    9 min

  • Cover diagram for “Stateless vs Stateful Services: Why Everyone Says "Go Stateless"”

    System Design

    Stateless vs Stateful Services: Why Everyone Says "Go Stateless"

    Your app works perfectly on one server. Add a second behind a load balancer and users start getting logged out at random. "Make it stateless" is the standard advice, but the state doesn't disappear; it moves. Here's what stateless really means, what sticky sessions cost you, and when keeping state in the process is the right call.

    9 min

  • Cover diagram for “SLIs, SLOs, and SLAs: Measuring Reliability with Error Budgets”

    DevOps & Cloud

    SLIs, SLOs, and SLAs: Measuring Reliability with Error Budgets

    "99.9% uptime" sounds like a number everyone agrees on until you ask what counts as up, measured where, over which month. SLIs, SLOs, and SLAs answer those questions, and error budgets turn them into decisions about when to ship and when to stop. Here's how they fit together and how to alert on them without paging people for nothing.

    8 min

  • Cover diagram for “Insecure Direct Object References (IDOR): When Your IDs Leak Data”

    Security

    Insecure Direct Object References (IDOR): When Your IDs Leak Data

    Change the number in the URL and you're reading someone else's invoice. IDOR, also called Broken Object Level Authorization, is the top risk in the OWASP API Security list, and it survives code review because every individual endpoint looks fine. Here's why it happens, why UUIDs don't fix it, and how to make the check impossible to forget.

    9 min

  • Cover diagram for “Time Zones in Databases: Why Your Timestamps Are Lying”

    Databases

    Time Zones in Databases: Why Your Timestamps Are Lying

    A timestamp column that looks fine in development can quietly shift by hours in production, merge two events into one during a DST change, or put a meeting at the wrong time after a government changes its clocks. Here's what your database actually stores, and how to choose between instants, wall times, and zones.

    10 min

  • Cover diagram for “CORS Explained: Why Your API Call Is Blocked”

    Security

    CORS Explained: Why Your API Call Is Blocked

    It works in curl, it works in Postman, and the browser still says 'blocked by CORS policy.' CORS isn't a firewall on your API. It's the browser deciding whether your JavaScript may read a response. Once you see it that way, the errors make sense, and so do the misconfigurations that turn it into a real vulnerability.

    11 min

32 more to read