User opens the app. Show the nearest 10 coffee shops. Sounds simple until you realize ’nearest’ means computing distance against millions of locations in under 100ms.
Posts for: #Architecture
Quadtrees: When Fixed Grids Aren’t Enough
Manhattan has 50,000 restaurants. Rural Wyoming has 3 per county. A fixed-size grid wastes cells on empty space and overloads dense areas. Quadtrees adapt.
Geohashing: Turning Coordinates into Searchable Strings
Your user is at latitude 37.7749, longitude -122.4194. Your database has 10 million locations. A full table scan comparing every coordinate pair isn’t going to work.
Work Stealing: Dynamic Load Balancing Without a Coordinator
You split work evenly across 4 threads. Two finish in 10ms, two take 10 seconds. Half your CPU sits idle while the other half grinds. Work stealing fixes this.
Delayed Message Delivery: Execute This in 30 Minutes
Send a reminder in 24 hours. Retry this job in 5 minutes. Expire this hold at midnight. Delayed execution is everywhere, and Thread.sleep isn’t the answer.
Leader Election: Picking One Node to Rule
Three nodes, one job. Without leader election, all three run it simultaneously. With leader election, exactly one does the work while the others stand by.
MapReduce: Processing Data That Won’t Fit on One Machine
Your dataset is 10TB. One machine can’t hold it, let alone process it. MapReduce splits the work across hundreds of machines with a deceptively simple API.
Checkpointing: Resuming Long-Running Jobs Without Starting Over
A batch job runs for three hours and crashes at hour two. Without checkpointing, you restart from zero. With it, you lose ten minutes of work.
Priority Queues in Distributed Systems
FIFO queues treat every message equally. But urgent config updates shouldn’t wait behind a thousand bulk sync jobs. Priority queues fix this, if you handle starvation.
Reconciliation: When Your Systems Disagree
Your database says one thing. The external system says another. Reconciliation is how you find the drift before your users do.
State Machines: Making Distributed Workflows Predictable
Boolean flags and status strings create impossible states. An explicit state machine tells you exactly where a workflow is, what transitions are valid, and how to recover.
Two-Phase Commit: The Original Distributed Transaction
Two-phase commit guarantees atomicity across multiple databases. It also blocks everything if the coordinator dies. Here’s why microservices moved on.
Input Validation and Abuse Prevention in Distributed Systems
Every public write endpoint is an abuse vector. Layered defense with validation, rate limiting, and async scanning keeps your system safe without killing performance.
SLOs and Error Budgets: When Good Enough is a Number
100% availability is impossible and pursuing it wastes engineering time. SLOs turn reliability into a number you can reason about.
Base62 Encoding: Turning Numbers into Short Strings
A 64-bit integer is 19 digits. Encode it in base62 and it’s 7 characters. The math behind compact, URL-safe identifiers.
Distributed ID Generation: Snowflake and Friends
Auto-increment IDs break the moment you have more than one database. Snowflake IDs, UUIDs, and database sequences each solve this differently.
Event Aggregation: When 47 Notifications Become One
Showing every individual event overwhelms users. Grouping related events into summaries is a distributed systems problem hiding as a UX problem.
Social Graphs at Scale: Storing Relationships in MySQL
A follows table with two columns seems trivial. Until you need to query it from both directions, across shards, for millions of users.
Relevance Scoring: Why Chronological Order Breaks Down
Showing content in time order is simple until your users follow thousands of sources. Scoring and ranking turns a firehose into a useful stream.
Pre-Signed URLs: Uploading Files Without Touching Your Servers
Routing file uploads through your API server is a scaling bottleneck. Pre-signed URLs let clients upload directly to object storage.
Presence Systems: Who’s Online and How You Know
Green dot means online. Simple, right? Behind that dot is a distributed system making heartbeat-based guesses about user liveness.
Fan-Out Strategies: Write-Time vs Read-Time
User posts an update. Do you push it to all followers immediately, or let them pull it when they check? The trade-off shapes your entire architecture.
WebSockets vs Long Polling: Choosing a Real-Time Transport
Your client needs real-time updates from the server. HTTP wasn’t built for this. Here’s how long polling, SSE, and WebSockets solve it differently.
Database Migrations Without Downtime
ALTER TABLE on a 2M row table locks it for minutes. Your users see errors. Here’s how expand-contract and shadow writes let you migrate without downtime.
Multi-Level Caching: L1, L2, and Beyond
Why one cache isn’t enough. How to layer local, distributed, and CDN caches for maximum performance without losing your mind on consistency.
Cache Invalidation: The Hard Problem
There are only two hard things in computer science: cache invalidation and naming things. Here’s why invalidation is so tricky, and what actually works.
Caching Patterns: Cache-Aside, Write-Through, and Friends
The four fundamental caching patterns every engineer should know. When to use cache-aside vs write-through vs write-behind vs read-through.
Gossip Protocols: How Rumors Keep Systems Alive
How distributed systems spread information without a central coordinator. The surprisingly effective technique of random peer-to-peer chatter.
Raft: The Understandable Consensus Algorithm
How distributed systems agree on state. A practical look at Raft’s Leader Election and Log Replication, finally making sense of consensus.
The CAP Theorem: The Cliché I Tried to Avoid
Why the CAP Theorem is the most misunderstood rule in system design. Addressing the ‘Pick 2’ lie and how it sets the stage for consensus algorithms.