learningto/pass

System Design Basics

AdvancedConcepts

Google senior interviews always include system design. You need to design scalable distributed systems covering load balancing, caching, databases, and consistency tradeoffs. Know how Google-scale systems work.

AVG TIME
O(1)
SPACE
O(n)
BEST
O(1)
WORST
O(n)

Key Concepts

  • 1Start with requirements: QPS, data size, read/write ratio, latency SLAs
  • 2CAP theorem: Consistency, Availability, Partition tolerance - pick 2
  • 3Horizontal scaling + load balancing for stateless services
  • 4Caching layers: CDN, application cache (Redis), database query cache
  • 5Database sharding strategies: range-based, hash-based, directory-based

In Python

Concept to Code- 3 structures for this topic
declare
seen = {} # or seen = dict()
common ops
seen[key] = val
O(1)
key in seen
O(1)
seen.get(key, default)
O(1)
del seen[key]
O(1)
seen.keys()
O(n)
seen.items()
O(n)
say in interview
"I'll use a hash map for O(1) lookups"
In Python, dict preserves insertion order (since 3.7). In interviews, don't rely on this unless asked.

Math You Need For This

A latency number cheat sheet: L1 cache = 1ns, main memory = 100ns, SSD = 100µs, disk = 10ms, network round trip = 100ms. These numbers differ by orders of magnitude and determine system architecture.

Required concepts
Key math ideas
1 / 2

Orders of magnitude - powers of 10

Each "order of magnitude" is 10x bigger. A system handling 1,000 requests/second versus 100,000 requests/second is two orders of magnitude different - not 100 units, but 100x. System design constantly compares numbers at different orders of magnitude.

Visual: A number line that is exponential, not linear. Each tick mark is 10x bigger than the previous. 1, 10, 100, 1,000, 10,000, 100,000, 1,000,000. The visual distance between 1 and 10 looks the same as between 1,000 and 10,000.

Think of it this way: The difference between a lemonade stand and a restaurant and a fast food chain and a global food company. Same product, but each order of magnitude in scale requires fundamentally different systems.

For algorithms: System design interviewers often test whether you can reason about scale. "Handle 10 million users" means understanding what changes at each order of magnitude, not just adding more servers.

Interactive 3D Visualization

Array
Access: O(1)Search: O(n)Space: O(n)
Drag to orbit - Scroll to zoom

Python Implementation

example.py
Loading...
Now try it yourself
1 challenge with test cases and AI feedback
Practice Now

Complexity Analysis

1481216nlog n1n (input size)
COMMON OPERATIONS
Array
Access:O(1)
Search:O(n)
Insert end:O(1)*
Insert mid:O(n)
Hash Map
Get/Set:O(1)*
Delete:O(1)*
Search value:O(n)
Iterate:O(n)
Linked List
Access:O(n)
Search:O(n)
Insert head:O(1)
Delete known:O(1)
Binary Search
Search:O(log n)
Insert:O(log n)
Balanced BST
Search:O(log n)
Insert:O(log n)
Delete:O(log n)
Heap
Peek min/max:O(1)
Push:O(log n)
Pop:O(log n)
Heapify:O(n)
Graph (BFS/DFS)
Traversal:O(V+E)
Dijkstra (heap):O((V+E) log V)
Merge / Quick Sort
Sort:O(n log n)
Space (merge):O(n)
Space (quick):O(log n)

* amortized average case

READY TO TEST YOURSELF?

Put System Design Basics into practice

The best way to lock in what you've learned is to write code. Solve real interview-style problems right now.

System Design Basics