Keyboard shortcuts

/ or ⌘/Ctrl K
Find a note
j / k
Next / previous section or linked note
h / l
Collapse or go to parent / expand or enter
e or Alt-click
Read a linked note here
o
Open focused note on its own
g g / G
First / last section or linked note
g h / g a
Home / all notes
g b / g t
Backlinks / table of contents
t
Cycle System, Light, Dark
? / Esc
Show / close this reference

Search: ↑/↓ or Ctrl N/P, Enter to open. Shortcuts pause while typing.

load balancing [e1b7cc98]

distributed systems

1. Algorithms Per Server

2024-02-10_18-20-00_screenshot.png

1.1. Leaky Bucket Algorithm [e4795d65]

  • Has known properties of capacity ($C$), inflow rate ($R_{in}$), and outflow rate ($R_{out}$).
  • As requests come in, check if the bucket is full, and drop it
  • Good for avoiding bursts of requests downstream
  • Slow processing will stall the entire queue

1.2. Token Bucket Algorithm

  • Bucket has predefined capacity of tokens, each bucket is periodically filled with tokens at a constant rate. Checks for tokens in a bucket every time we recieve a request
  • Similar to leaky bucket, but allows for bursts of traffic to come in, and space efficient. At time cutoffs for token refills, however, it could slightly exceed

1.3. Fixed Window

2024-02-10_18-15-30_screenshot.png

  • Same as the others, but has problems like the token one where edges can allow for more requests than normal.
  • Biggest danger is that a consistent burst of traffic at the window edges could overflow

1.4. Sliding Window Log

  • LB keeps track of timestamps when things arrive, whenever a request arrives, we look back and count how many are available.
  • Avoids the issue of edges, but requires extra memory

1.5. Sliding Window Counter

  • Divide time into various windows. Keep a sliding window over them, and count how many.
  • Avoids the issue edges, but has problems in that it assumes previous window requests are distributed evenly across the window time
  • Smoothes out the burst

2. Distribution Algorithms

2.1. Consistent Hashing

2.2. Adya et al: Slicer Auto-Sharding for Datacenter Applications.pdf

3. Implementations