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.
Posts for: #Performance
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.
Trie Data Structures: Prefix Search in Milliseconds
User types three characters and expects instant suggestions. A hash map can’t do prefix lookups. A trie can, in O(k) time where k is the query length.
Approximate Counting: HyperLogLog and Count-Min Sketch
Counting unique items across billions of events. A HashSet needs gigabytes. HyperLogLog does it in 12KB. The trick is accepting a little error.
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.
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.
Cursor-Based Pagination: Why Offset Breaks at Scale
OFFSET 50000 makes MySQL scan 50,000 rows just to skip them. Cursor pagination stays fast no matter how deep you go.
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.
Thundering Herd
Cache expires. 10,000 requests hit the database simultaneously. Your DB collapses. How request coalescing and probabilistic expiration prevent the stampede.
Tail Latency: The P99 Problem
Your average latency looks great. Your P99 is a disaster. Why tail latency matters more than averages, and what you can actually do about it.
Timeouts: The Hardest Easy Problem
Why setting timeouts is harder than it looks. Cascading failures, timeout budgets, and the art of picking the right number.
Connection Pooling: Why Opening Connections Is Expensive
The hidden cost of database connections. How connection pools work, why they matter, and how to size them without guessing.
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 Stampede: When Expiry Causes Chaos
What happens when a popular cache key expires and thousands of requests hit your database at once. Three patterns to prevent the thundering herd.
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.
The In-Memory Trap: Why Objects Are Slow
In-memory doesn’t always mean fast. How shifting from object-based to vector-based storage (Apache Arrow) delivered a 13x performance boost.
Materialized Views: The Read Optimization Pattern
Why standard views are just aliases and how materialized views act as an ‘in-database cache’ to solve the cross-shard query problem.
Backpressure: When Consumers Can’t Keep Up
Handling slow consumers in distributed systems. Queue growth, memory exhaustion, and strategies for applying backpressure - rejection, rate limiting, and flow control.
Query Execution Plans: Reading EXPLAIN Like a Map
Stop staring at EXPLAIN output confused. Learn to read MySQL execution plans like a map and find the root cause of slow queries in seconds, not hours.
The Hidden Cost of JOINs
Every JOIN multiplies query complexity. Learn the three JOIN strategies databases use and when denormalization beats JOIN performance by 30x.
Indexing Strategies That Actually Work
More indexes don’t mean faster queries. Learn when to add, remove, and optimize database indexes. Real examples of 7x performance gains through strategic indexing.
The Query Optimization Framework
Stop guessing at performance problems. Learn the 5-step systematic framework for debugging slow queries that helped reduce query times from 2+ seconds to 30ms.