reactive revealed part 2: scalability, elasticity and location transparency in reactive systems

Post on 24-Jan-2017

4.632 Views

Category:

Software

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Elasticity, Scalability &Location Transparencyin Reactive Systems

√Deputy CTO

@viktorklang

1. Lead-In

2. Scale-Up

3. Scale-Out

4. Show-Down

2

1. Lead-In

2. Scale-Up

3. Scale-Out

4. Show-Down

3

The rules of the game

have changed

5

Yesterday TodaySingle machines Clusters of machines

Single core processors Multicore processors

Expensive RAM Cheap RAM

Expensive disk Cheap disk

Slow networks Fast networks

Few concurrent users Lots of concurrent users

Small data sets Large data sets

Latency in seconds Latency in milliseconds

Tomorrow

The Principles of Reactive Systems

Scale on Demand?

Why do we need to

11

E l a s t i c i t y

«Lagom is a Swedish word, meaning "just the right amount"»

— Wikipedia

scalability?what is

But

15

“A service is said to be scalable if when we increase the resources in a system, it results in increased performance in

a manner proportional to resources added.” - Werner Vogels

vs Scalability

Performance

1. Lead-In

2. Scale-Up

3. Scale-Out

4. Show-Down

17

UP

Scale

and down

19

Modern CPU architecture

The CPU is a notorious gambler

20

Maximize

Locality of Reference

Minimize

Contention

Common points of

23

ApplicationPhysical

contention

Block

24

Never ever

Async

25

BE

26

NOTHINGshare

DIVIDE&

conquer27

28

Single Writer Principle

IO device

Producers

CONTENDED

IO device

Producers Writer

UNCONTENDED

29

30

Needs to be async and non-blockinga l l t h e w a y d o w n

31

Universal Scalability Law

«N is the number of users;or the number of CPUs, is the contention level,α the coherency latency.β

C is the relative capacity»

Perfect

32

Load

Thro

ughp

ut

Imperfect

33

Load

Thro

ughp

ut

Bounded

34

Load

Thro

ughp

ut

Regressive

35

Load

Thro

ughp

ut

The Role of Immutable State

• Great to represent facts

• Messages and Events

• Database snapshots

• Representing the succession of time

• Mutable State is ok if local and contained

• Allows Single-threaded processing

• Allows single writer principle

• Feels more natural

• Publish the results to the world as Immutable State

36

on Demand

Scale

1. Lead-In

2. Scale-Up

3. Scale-Out

4. Show-Down

38

OUT

Scale

(and IN)

• Mobile / IoT

• HTTP and Micro Services

• “NoSQL” DBs

• Big Data

• Fast Data

40

Distributed Computing is the new

normal

Reality check

• separation in space & time gives us

• communication for coordination

• variable delays

• partial failures

• partial/local/stale knowledge

41

Cluster/Rack/Datacenter

Cluster/Rack/Datacenter

Cluster/Rack/Datacenter

Middleware

Node Node Node

42

Node

43

1. The network is reliable2. Latency is zero3. Bandwidth is infinite4. The network is secure5. Topology doesn't change6. There is one administrator7. Transport cost is zero8. The network is homogeneous

Peter Deutsch’s 8 Fallacies of

Distributed Computing

Maximize

Locality of Reference

Strong Consistency

47

Linearizability

“Under linearizable consistency, all operations appear to have executed atomically in an order that is consistent with the

global real-time ordering of operations.” - Herlihy & Wing 1991

Strong Consistency Protocols

(Coordination in the Cluster)

Minimize

Contention

50

CAPTheorem

Consistency

Eventual

52

CRDTCvRDTs/CmRDTs

53

“In general, application developers simply do not implement large scalable applications assuming

distributed transactions.”- Pat Helland

Life beyond Distributed Transactions:

an Apostate’s Opinion

The Event Log

• Append-Only Logging

• Database of Facts

• Two models:

• One single Event Log

• Strong Consistency

• Multiple sharded Event Logs

• Strong + Eventual Consistency

56

1. Lead-In

2. Scale-Up

3. Scale-Out

4. Show-Down

57

NOTHING

58

share

TRANSPARENCY

59

location

DataCenter

61

DataCenter

ClusterCluster MachineMachine JVMJVMNodeNode

ThreadThread CPUCPUCPU

SocketCPU

Socket

CPUCore

CPUCore

CPUL1/L2Cache

CPUL1/L2Cache

62

Scaling Up / Out is essentially

the same thing

Elasticity requires amessage-drivenarchitecture

Summary• Isolate & Contain + Distribute & Replicate

• Single Purpose Components

• Communicate asynchronously

• Divide & Conquer

• Avoid coordination & minimize contention

• Embrace inconsistency

• Strive for lagom amount of utilisation

64

EXPERT TRAININGDelivered on-site for Akka, Spark, Scala and Play

Help is just a click away. Get in touch with Typesafe about our training courses.

• Intro Workshop to Apache Spark • Fast Track & Advanced Scala• Fast Track to Akka with Java or Scala• Fast Track to Play with Java or Scala• Advanced Akka with Java or Scala

Ask us about local trainings available by 24 Typesafe partners in 14 countries around the world.

CONTACT US Learn more about on-site training

top related