Beyond the buzzword: a reactive web-appliction in practice
-
Upload
manuel-bernhardt -
Category
Engineering
-
view
133 -
download
2
Transcript of Beyond the buzzword: a reactive web-appliction in practice
![Page 1: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/1.jpg)
Beyond the buzzword:
a reac%ve web applica*on in prac*ce
Manuel Bernhardt - @elmanu
Enterprise Java User Group Linz - September 2016
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 2: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/2.jpg)
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 3: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/3.jpg)
Agenda
1. Reac've applica'ons: why, what
2. Small Reac've Web Applica'on
3. Deployment & Load tes'ng
If you have a ques-on, shoot!
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 4: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/4.jpg)
Manuel Bernhardt
• I help mid-sized telecommunica4ons and technology companies ge7ng started with reac4ve microservice-based systems to speed up and scale IT delivery
• h=p://manuel.bernhardt.io
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 5: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/5.jpg)
Manuel Bernhardt
• I help mid-sized telecommunica4ons and technology companies ge7ng started with reac4ve microservice-based systems to speed up and scale IT delivery
• h=p://manuel.bernhardt.io
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 6: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/6.jpg)
Reac%ve applica%ons: why, what
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 7: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/7.jpg)
Root cause 1:evolu&on of so+ware architecture
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 8: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/8.jpg)
"Good old days" architecture
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 9: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/9.jpg)
"3 $er" architecture
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 10: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/10.jpg)
"Cloud" architecture
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 11: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/11.jpg)
"Microservices" architecture
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 12: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/12.jpg)
=> Increasing amount of network I/O
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 13: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/13.jpg)
=> Increasing amount of network I/O
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 14: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/14.jpg)
Root cause 2: evolu.on of hardware
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 15: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/15.jpg)
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 16: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/16.jpg)
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 17: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/17.jpg)
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 18: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/18.jpg)
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 19: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/19.jpg)
Why reac)ve ?
1. Distributed systems are the rule, not the excep1on
2. Programming needs to acknowledge the existance of many hardware threads, the lost opportunity of not using it & the cost of locking
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 20: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/20.jpg)
What reac)ve ?
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 21: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/21.jpg)
Reac%ve systems are distributed systems
(they're a subset thereof)
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 22: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/22.jpg)
What's the main difference between a distributed system and a non-
distributed system?
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 23: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/23.jpg)
What's the main difference between a distributed system and a non-
distributed system?
Distributed systems fail much more o-en (and in much stranger ways)
than non-distributed onesEnterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 24: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/24.jpg)
FailureFailure is a first-class ci.zen in reac.ve systems. They're designed for failure.
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 25: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/25.jpg)
Handling failure
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 26: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/26.jpg)
Handling failure• checked excep*ons are a terrible idea in the context of reac*ve /
distributed systems
• languages, tools and pa<erns for streamlining failure handling: Func*onal Programming, Futures, Message Passing
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 27: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/27.jpg)
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 28: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/28.jpg)
Don't try to hide the network!• CORBA, RPC & friends: trying to abstract away the network
• what happens when the network call
• ... fails
• ... is slow
• ... is some%mes slow
• ... someAmes fails, someAmes doesn't
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 29: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/29.jpg)
Don't try to hide the network!
• ignoring of the Fallacies of Distributed Compu8ng (Deutsch & Gosling)
• ignoring the CAP theorem
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 30: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/30.jpg)
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 31: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/31.jpg)
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 32: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/32.jpg)
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 33: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/33.jpg)
Reac%ve architectural pa/ern
h"p://www.reac,vemanifesto.org
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 34: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/34.jpg)
Reac%ve Systems - Conclusion
• Reac&ve Systems are designed for failure
• Reac&ve Systems are distributed, replicated accross several nodes (can scale up and down)
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 35: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/35.jpg)
Let's build a small Reac0ve Web Applica0on
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 36: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/36.jpg)
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 37: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/37.jpg)
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 38: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/38.jpg)
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 39: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/39.jpg)
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 40: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/40.jpg)
Actors
• lightweight objects
• send and receive messages (mailbox)
• can have children (supervision)
"Long-lived" async computa5on
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 41: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/41.jpg)
CODING
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 42: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/42.jpg)
Futuresscala.concurrent.Future[T]
• holds a value of type T
• can either fail or succeed
• async code does not block a thread while wai8ng for comple8on
"Short-lived" async computa6on
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 43: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/43.jpg)
Pipeakka.pattern.pipe
• bridge between Futures and Actors
• implemented as anonymous actor
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 44: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/44.jpg)
Pipeakka.pattern.pipe
• bridge between Futures and Actors
• implemented as anonymous actor
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 45: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/45.jpg)
Circuit Breakerakka.pattern.CircuitBreaker
• helpful when dealing with legacy / slow systems & prevents cascading failure
• like an electric circuit breaker, trips when there's a surge
• trips a=er a given number of failures, for a given >meout, then a?empts reset
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 46: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/46.jpg)
DeploymentEnterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 47: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/47.jpg)
Deployment• stand-alone vs. "elas/c deployment"
• elas/c, fault-tolerant is not trivial
• use a managed service / solu/on
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 48: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/48.jpg)
Deployment
• Lightbend ConductR
• automated cluster management for Play / Akka / ... applica>ons
• automated node failure & network par++on resolu+on
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 49: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/49.jpg)
Deployment
• fully managed opera0ons
• auto scalability feature (horizontal & ver0cal)
• a<rac0ve pricing
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 50: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/50.jpg)
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 51: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/51.jpg)
Load tes)ngEnterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 52: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/52.jpg)
Gatling
• open-source load tes0ng framework
• built with Scala, Akka and Ne=y
• two phases: record and run
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 53: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/53.jpg)
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 54: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/54.jpg)
Gatling simula,on file// ...setUp( scn.inject( nothingFor(4 seconds), rampUsers(100) over(10 seconds), atOnceUsers(10), constantUsersPerSec(2) during(15 seconds) randomized, splitUsers(500) into ( rampUsers(50) over(10 seconds) ) separatedBy(2 seconds) ).protocols(httpProtocol))
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 55: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/55.jpg)
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 56: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/56.jpg)
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 57: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/57.jpg)
Bees with machine guns
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 58: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/58.jpg)
Configuring all the things
• Installing Python & bees with machine guns
• AWS console (keys, security group w/ SSH access)
• boto config file
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 59: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/59.jpg)
Configuring all the things
~/.boto
[Credentials]aws_access_key_id = foobar1aws_secret_access_key = foobar2
[Boto]debug = 2
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 60: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/60.jpg)
A"ack!
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu
![Page 61: Beyond the buzzword: a reactive web-appliction in practice](https://reader031.fdocuments.in/reader031/viewer/2022030306/58cf73181a28abe6688b5579/html5/thumbnails/61.jpg)
Thank you!Ques%ons & Comments ?
• h#p://manuel.bernhardt.io
• @elmanu
Enterprise JUG September 2016 Linz - manuel.bernhardt.io - @elmanu