Algorithmic Systems Patterns
At the SDE-2 level, algorithms aren't just about traversing an array in O(n) time. They are about how data structures interact with hardware, concurrency, and distributed scaling.
Thread-Safe LRU Cache
Standard std::unordered_map plus std::list isn't thread-safe. A common backend pattern is implementing thread-safe eviction policies. While a single global mutex works conceptually, real-world implementations require Lock Striping or Sharding by key hash to prevent disastrous thread contention under load.
Token Bucket Rate Limiting
API Gateways require distributed rate limiting. The Token Bucket algorithm allows burst traffic (unlike Leaky Bucket) while maintaining an average rate. In a distributed environment, this is often implemented via Redis Lua scripts to guarantee atomicity.
Consistent Hashing
Traditional modulo hashing (`hash(key) % N`) forces a complete data rebalance when a node is added or lost. System-level patterns map hashes to a ring topology, and nodes to points on the ring. Finding a node becomes a binary search (`std::lower_bound`) on the sorted ring array, resulting in O(log N) routing overhead with minimal key movement.