Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems
-
Upload
typesafeinc -
Category
Software
-
view
4.632 -
download
0
Transcript of Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems
![Page 1: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/1.jpg)
Elasticity, Scalability &Location Transparencyin Reactive Systems
√Deputy CTO
@viktorklang
![Page 2: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/2.jpg)
1. Lead-In
2. Scale-Up
3. Scale-Out
4. Show-Down
2
![Page 3: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/3.jpg)
1. Lead-In
2. Scale-Up
3. Scale-Out
4. Show-Down
3
![Page 4: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/4.jpg)
The rules of the game
have changed
![Page 5: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/5.jpg)
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
![Page 6: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/6.jpg)
Tomorrow
![Page 7: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/7.jpg)
The Principles of Reactive Systems
![Page 8: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/8.jpg)
Scale on Demand?
Why do we need to
![Page 9: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/9.jpg)
11
E l a s t i c i t y
«Lagom is a Swedish word, meaning "just the right amount"»
— Wikipedia
![Page 10: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/10.jpg)
scalability?what is
But
![Page 11: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/11.jpg)
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
![Page 12: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/12.jpg)
vs Scalability
Performance
![Page 13: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/13.jpg)
1. Lead-In
2. Scale-Up
3. Scale-Out
4. Show-Down
17
![Page 14: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/14.jpg)
UP
Scale
and down
![Page 15: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/15.jpg)
19
Modern CPU architecture
![Page 16: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/16.jpg)
The CPU is a notorious gambler
20
![Page 17: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/17.jpg)
Maximize
Locality of Reference
![Page 18: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/18.jpg)
Minimize
Contention
![Page 19: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/19.jpg)
Common points of
23
ApplicationPhysical
contention
![Page 20: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/20.jpg)
Block
24
Never ever
![Page 21: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/21.jpg)
Async
25
BE
![Page 22: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/22.jpg)
26
NOTHINGshare
![Page 23: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/23.jpg)
DIVIDE&
conquer27
![Page 24: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/24.jpg)
28
Single Writer Principle
IO device
Producers
CONTENDED
IO device
Producers Writer
UNCONTENDED
![Page 25: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/25.jpg)
29
![Page 26: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/26.jpg)
30
Needs to be async and non-blockinga l l t h e w a y d o w n
![Page 27: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/27.jpg)
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»
![Page 28: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/28.jpg)
Perfect
32
Load
Thro
ughp
ut
![Page 29: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/29.jpg)
Imperfect
33
Load
Thro
ughp
ut
![Page 30: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/30.jpg)
Bounded
34
Load
Thro
ughp
ut
![Page 31: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/31.jpg)
Regressive
35
Load
Thro
ughp
ut
![Page 32: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/32.jpg)
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
![Page 33: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/33.jpg)
on Demand
Scale
![Page 34: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/34.jpg)
1. Lead-In
2. Scale-Up
3. Scale-Out
4. Show-Down
38
![Page 35: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/35.jpg)
OUT
Scale
(and IN)
![Page 36: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/36.jpg)
• Mobile / IoT
• HTTP and Micro Services
• “NoSQL” DBs
• Big Data
• Fast Data
40
Distributed Computing is the new
normal
![Page 37: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/37.jpg)
Reality check
• separation in space & time gives us
• communication for coordination
• variable delays
• partial failures
• partial/local/stale knowledge
41
![Page 38: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/38.jpg)
Cluster/Rack/Datacenter
Cluster/Rack/Datacenter
Cluster/Rack/Datacenter
Middleware
Node Node Node
42
Node
![Page 39: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/39.jpg)
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
![Page 40: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/40.jpg)
Maximize
Locality of Reference
![Page 41: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/41.jpg)
Strong Consistency
![Page 42: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/42.jpg)
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
![Page 43: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/43.jpg)
Strong Consistency Protocols
![Page 44: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/44.jpg)
(Coordination in the Cluster)
Minimize
Contention
![Page 45: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/45.jpg)
50
CAPTheorem
![Page 46: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/46.jpg)
Consistency
Eventual
![Page 47: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/47.jpg)
52
CRDTCvRDTs/CmRDTs
![Page 48: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/48.jpg)
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
![Page 49: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/49.jpg)
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
![Page 50: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/50.jpg)
1. Lead-In
2. Scale-Up
3. Scale-Out
4. Show-Down
57
![Page 51: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/51.jpg)
NOTHING
58
share
![Page 52: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/52.jpg)
TRANSPARENCY
59
location
![Page 53: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/53.jpg)
DataCenter
61
DataCenter
ClusterCluster MachineMachine JVMJVMNodeNode
ThreadThread CPUCPUCPU
SocketCPU
Socket
CPUCore
CPUCore
CPUL1/L2Cache
CPUL1/L2Cache
![Page 54: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/54.jpg)
62
Scaling Up / Out is essentially
the same thing
![Page 55: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/55.jpg)
Elasticity requires amessage-drivenarchitecture
![Page 56: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/56.jpg)
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
![Page 57: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/57.jpg)
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
![Page 58: Reactive Revealed Part 2: Scalability, Elasticity and Location Transparency in Reactive Systems](https://reader036.fdocuments.in/reader036/viewer/2022062822/588638901a28aba0188b5f1f/html5/thumbnails/58.jpg)