load balancing is impossible

48
LOAD BALANCING IS IMPOSSIBLE

Upload: fastly

Post on 08-Jan-2017

1.177 views

Category:

Software


1 download

TRANSCRIPT

Page 1: Load balancing is impossible

L O A D B A L A N C I N GI S

I M P O S S I B L E

Page 2: Load balancing is impossible

SLIDE

LOAD BALANCING IS IMPOSSIBLE

Tyler McMullen

[email protected]

@tbmcmullen

2

Page 3: Load balancing is impossible

WHAT IS LOAD BALANCING?

Page 4: Load balancing is impossible

[DIAGRAM DESCRIBING LOAD BALANCING]

Page 5: Load balancing is impossible

[ALLEGORY DESCRIBING LOAD BALANCING]

Page 6: Load balancing is impossible

SLIDELOAD BALANCING IS IMPOSSIBLE 6

Abstraction Balancing LoadFailure

Treat many servers as oneSingle entry point

Simplification

Transparent failoverRecover seamlessly

SimplificationSpread the load efficiently across servers

Why Load Balance?

Three major reasons. The least of which is balancing load.

Page 7: Load balancing is impossible

R A N D O M

T H E I N G L O R I O U S D E F A U LT

A N D B A N E O F M Y E X I S T E N C E

Page 8: Load balancing is impossible

SLIDE

LOAD BALANCING IS IMPOSSIBLE

What’s good about random?

8

• Simplicity

• Few edge cases

• Easy failover

• Works identically when distributed

Page 9: Load balancing is impossible

SLIDE

LOAD BALANCING IS IMPOSSIBLE

What’s bad about random?

9

• Latency• Especially long-tail latency• Useable capacity

Page 10: Load balancing is impossible

B A L L S - I N T O - B I N S

Page 11: Load balancing is impossible

I f you throw m bal ls into n b ins,what is the maximum load

of any one bin?

Page 12: Load balancing is impossible
Page 13: Load balancing is impossible

importnumpyasnpimportnumpy.randomasnr

n=8#numberofserversm=1000#numberofrequests

bins=[0]*n

forchosen_bininnr.randint(0,n,m):bins[chosen_bin]+=1

printbins

[129,100,134,113,117,136,148,123]

Page 14: Load balancing is impossible

importnumpyasnpimportnumpy.randomasnr

n=8#numberofserversm=1000#numberofrequests

bins=[0]*n

forweightinnr.uniform(0,2,m):chosen_bin=nr.randint(0,n)bins[chosen_bin]+=weight

printbins

[133.1,133.9,144.7,124.1,102.9,125.4,114.2,121.3]

Page 15: Load balancing is impossible

How do you modelrequest latency?

Page 16: Load balancing is impossible

Log-normal Distribution

50th: 0.675th: 1.2 95th: 3.1

99th: 6.0

99.9th: 14.1

MEAN: 1.0

Page 17: Load balancing is impossible

mu=0.0sigma=1.15lognorm_mean=math.e**(mu+sigma**2/2)

desired_mean=1.0

defnormalize(value):returnvalue/lognorm_mean*desired_mean

forweightinnr.lognormal(mu,sigma,m):chosen_bin=nr.randint(0,n)bins[chosen_bin]+=normalize(weight)

[128.7,116.7,136.1,153.1,98.2,89.1,125.4,130.4]

Page 18: Load balancing is impossible

mu=0.0sigma=1.15lognorm_mean=math.e**(mu+sigma**2/2)

desired_mean=1.0baseline=0.05

defnormalize(value):return(value/lognorm_mean*(desired_mean-baseline)+baseline)

forweightinnr.lognormal(mu,sigma,m):chosen_bin=nr.randint(0,n)bins[chosen_bin]+=normalize(weight)

[100.7,137.5,134.3,126.2,113.5,175.7,101.6,113.7]

Page 19: Load balancing is impossible

THIS IS WHY

PERFECTION

IS IMPOSSIBLE

Page 20: Load balancing is impossible

WHY IS THAT A PROBLEM?

Page 21: Load balancing is impossible

WHAT EFFECT DOES IT HAVE?

Page 22: Load balancing is impossible

Random simulationActual distribution

Page 23: Load balancing is impossible

The probability of a single resource request avoiding the 99th percentile is 99%.

The probability of all N resource requests in a page avoidingthe 99th percentile is (99% ^ N).

99% ^ 69 = 49.9%

Page 24: Load balancing is impossible
Page 25: Load balancing is impossible

SO WHAT DO WE DO ABOUT IT?

Page 26: Load balancing is impossible

Random simulationJSQ simulation

Page 27: Load balancing is impossible
Page 28: Load balancing is impossible
Page 29: Load balancing is impossible
Page 30: Load balancing is impossible

L E T ’ S T H R O W A W R E N C H I N T O T H I S . . .

D I S T R I B U T E D L O A D B A L A N C I N G

A N D W H Y I T M A K E S E V E R Y T H I N G H A R D E R

Page 31: Load balancing is impossible

DISTRIBUTED RANDOM IS EXACTLY THE SAME

Page 32: Load balancing is impossible

DISTRIBUTED JOIN-SHORTEST-QUEUE IS A NIGHTMARE

Page 33: Load balancing is impossible
Page 34: Load balancing is impossible
Page 35: Load balancing is impossible
Page 36: Load balancing is impossible

mu=0.0sigma=1.15lognorm_mean=math.e**(mu+sigma**2/2)

desired_mean=1.0baseline=0.05

defnormalize(value):return(value/lognorm_mean*(desired_mean-baseline)+baseline)

forweightinnr.lognormal(mu,sigma,m):chosen_bin=nr.randint(0,n)bins[chosen_bin]+=normalize(weight)

[100.7,137.5,134.3,126.2,113.5,175.7,101.6,113.7]

Page 37: Load balancing is impossible

mu=0.0sigma=1.15lognorm_mean=math.e**(mu+sigma**2/2)

desired_mean=1.0baseline=0.05

defnormalize(value):return(value/lognorm_mean*(desired_mean-baseline)+baseline)

forweightinnr.lognormal(mu,sigma,m):a=nr.randint(0,n)b=nr.randint(0,n)chosen_bin=aifbins[a]<bins[b]elsebbins[chosen_bin]+=normalize(weight)

[130.5,131.7,129.7,132.0,131.3,133.2,129.9,132.6]

Page 38: Load balancing is impossible

[100.7,137.5,134.3,126.2,113.5,175.7,101.6,113.7]

[130.5,131.7,129.7,132.0,131.3,133.2,129.9,132.6]

STANDARD DEVIATION: 1.18

STANDARD DEVIATION: 22.9

Page 39: Load balancing is impossible

Random simulationJSQ simulationRandomized JSQ simulation

Page 40: Load balancing is impossible
Page 41: Load balancing is impossible
Page 42: Load balancing is impossible
Page 43: Load balancing is impossible
Page 44: Load balancing is impossible

A N O T H E R C R A Z Y I D E A

Page 45: Load balancing is impossible
Page 46: Load balancing is impossible

MY PROBLEM WITH THIS APPROACH...

A DIFFERENCE OF PERSPECTIVE

Page 47: Load balancing is impossible

WRAP UP

Page 48: Load balancing is impossible

SLIDE

LOAD BALANCING IS IMPOSSIBLE

THANKS BYE

[email protected]

@tbmcmullen

48