48
Maybe sticky sessions weren't a bad idea

Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

Maybe sticky sessions weren't a bad idea

Page 2: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen
Page 3: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen
Page 4: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen
Page 5: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen
Page 6: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen
Page 7: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen
Page 8: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen
Page 9: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

Trends

Tradeoffs

Nuance

Page 10: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

Status Quo

1. Write my PHP / Java / Rails

2. Connect it to an RDBMS

Buy lots of web servers & really big databases

Page 11: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

Storing state in an application

Page 12: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

• Just what the heck is state anyway?

• How do we store it today

• Some history

• Ok, but why?

• Caveats

• More information

Page 13: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

State of the state

• Data vs. behavior

• A coupling with time and space

Page 14: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

Time

• "happens before"

• memory barriers

• synchronization primitives

Page 15: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

Space

• threads

• processes

• servers

Page 16: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

State is a lens

def fact(i: Int) = { return i * fact(i - 1) }

Page 17: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

State is a lens

def doIt(i: Int) = { log("you sent $i") }

Page 18: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

State-less vs. State-ful

• Store data in a database

• Ship data => behavior

Page 19: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen
Page 20: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

State-less applications

• Deployed behind a load balancer

• Most common CRUD applications

Page 21: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen
Page 22: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

my engineers wrote this 😱

Page 23: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

This thing "works"

Page 24: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

don't care who's at fault

Page 25: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

State-ful

Page 26: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

State-ful applications

• Store data with the behavior

• Data does not move when worked on

Page 27: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

Sticky sessions

• Sticky sessions are an http concept that glues a session to a server

• Keeps sessions in a single place

Page 28: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

Sticky session

Server 1

Server 2

Server 3

Page 29: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

How

• DHT

• Non-D HT

Server 1

Server 2

Server 3

Server 1

Server 2

Server 3

Page 30: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

Major motivators

• Performance

• Correctness

• Programmer ergonomics

• Resilience

Page 31: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

Performance

2 min1s

14 hours6 days

Main memoryDisk

CPU cache

Network 500 μs50-150μs120ns1ns

Page 32: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

Performance

2 min1s

14 hours6 days

Main memoryDisk

CPU cache

Network 500 μs50-150μs120ns1ns

😀

Page 33: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

Performance

2 min1s

14 hours6 days

Main memoryDisk

CPU cache

Network 500 μs50-150μs120ns1ns

😭

Page 34: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

Correctness

• Data & behavior co-existing means we can reason about safely changing state

Page 35: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

Programmer Ergonomics

Page 36: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

Resilience

• Classes of error around txns

• Connection pools

• Failure can be handled

Page 37: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

How do we do this...

Page 38: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

Runtimes

• Long lived processes

• Threading model

• Control over memory

Page 39: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

Frameworks

• Supports some way to make remote calls

• Treats concurrency as a first class citizen

• A concept of clustering

Page 40: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

Some examples

Page 41: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

The downside

Page 42: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

Serialization

• De-serialize the future

• De-serialize the past

Page 43: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

Thundering herds

• Startup time (deployment)

• Rebalance performance

But it worked on my computer?!?

Page 44: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

Delicious memory

• Unbounded, in-memory data structures

But it worked on my computer?!?

Page 45: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

Copying Inspiration• Any distributed database: Riak, Cassandra,

Dynamo

• Akka distributed data / cluster sharding

• Orleans

• Unison

• CRDTs

Page 46: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

• Just what the heck is state anyway?

• How do we store it today

• Some history

• Ok, but why?

• Caveats

• More information

Page 47: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

@boulderdanh

Page 48: Maybe sticky sessions weren't a bad idea - SCALE · This thing "works" don't care who's at fault. State-ful. State-ful applications ... • Treats concurrency as a first class citizen

@boulderdanh