beyond the buzzword - a reactive application in practice

53
Beyond the buzzword: a reac%ve web applica*on in prac*ce Manuel Bernhardt - @elmanu Slovak Scala Users' Group - May 2016 Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Upload: manuel-bernhardt

Post on 16-Jan-2017

249 views

Category:

Engineering


2 download

TRANSCRIPT

Page 1: Beyond the Buzzword - a reactive application in practice

Beyond the buzzword:

a reac%ve web applica*on in prac*ce

Manuel Bernhardt - @elmanu

Slovak Scala Users' Group - May 2016

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 2: Beyond the Buzzword - a reactive application in practice

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 3: Beyond the Buzzword - a reactive application in practice

Agenda

1. Evolu(on of web applica(on architecture

2. Evolu(on of hardware

3. Small Reac(ve Web Applica(on

4. Deployment

If you have a ques-on, shoot!

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 4: Beyond the Buzzword - a reactive application in practice

Manuel Bernhardt

• I help established companies ge3ng started with using reac%ve applica%ons in their distributed systems infrastructure

• h9p://manuel.bernhardt.io

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 5: Beyond the Buzzword - a reactive application in practice

Manuel Bernhardt

• I help established companies ge3ng started with using reac%ve applica%ons in their distributed systems infrastructure

• h9p://manuel.bernhardt.io

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 6: Beyond the Buzzword - a reactive application in practice

A short (and mostly wrong)history of web applica1on

architectureSlovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 7: Beyond the Buzzword - a reactive application in practice

"Good old days" architecture

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 8: Beyond the Buzzword - a reactive application in practice

"3 $er" architecture

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 9: Beyond the Buzzword - a reactive application in practice

"Cloud" architecture

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 10: Beyond the Buzzword - a reactive application in practice

"Cloud" architecture

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 11: Beyond the Buzzword - a reactive application in practice

"Microservices" architecture

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 12: Beyond the Buzzword - a reactive application in practice

"Microservices" = emerging architecture

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 13: Beyond the Buzzword - a reactive application in practice

Trend: increasing amount of network I/O

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 14: Beyond the Buzzword - a reactive application in practice

Trend: increasing amount of network I/O

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 15: Beyond the Buzzword - a reactive application in practice

Reac%ve architectural pa/ern

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 16: Beyond the Buzzword - a reactive application in practice

Evolu&on of hardware

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 17: Beyond the Buzzword - a reactive application in practice

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 18: Beyond the Buzzword - a reactive application in practice

Evolu&on of CPUs

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 19: Beyond the Buzzword - a reactive application in practice

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 20: Beyond the Buzzword - a reactive application in practice

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 21: Beyond the Buzzword - a reactive application in practice

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 22: Beyond the Buzzword - a reactive application in practice

Evolu&on of memory

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 23: Beyond the Buzzword - a reactive application in practice

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 24: Beyond the Buzzword - a reactive application in practice

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 25: Beyond the Buzzword - a reactive application in practice

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 26: Beyond the Buzzword - a reactive application in practice

Conclusion

• many-core & distributed systems

• awesome hardware

• awesome so5ware? we need:

• explicit asynchronous programming

• explicit failure handling

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 27: Beyond the Buzzword - a reactive application in practice

Let's build a small Reac0ve Web Applica0on

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 28: Beyond the Buzzword - a reactive application in practice

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 29: Beyond the Buzzword - a reactive application in practice

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 30: Beyond the Buzzword - a reactive application in practice

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 31: Beyond the Buzzword - a reactive application in practice

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 32: Beyond the Buzzword - a reactive application in practice

Actors

• lightweight objects

• send and receive messages (mailbox)

• can have children (supervision)

"Long-lived" async computa5on

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 33: Beyond the Buzzword - a reactive application in practice

CODING

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 34: Beyond the Buzzword - a reactive application in practice

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

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 35: Beyond the Buzzword - a reactive application in practice

Pipeakka.pattern.pipe

• bridge between Futures and Actors

• implemented as anonymous actor

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 36: Beyond the Buzzword - a reactive application in practice

Pipeakka.pattern.pipe

• bridge between Futures and Actors

• implemented as anonymous actor

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 37: Beyond the Buzzword - a reactive application in practice

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

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 38: Beyond the Buzzword - a reactive application in practice

DeploymentSlovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 39: Beyond the Buzzword - a reactive application in practice

Deployment• stand-alone vs. "elas/c deployment"

• elas/c, fault-tolerant is not trivial

• use a managed service / solu/on

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 40: Beyond the Buzzword - a reactive application in practice

Deployment

• Lightbend ConductR

• automated cluster management for Play / Akka / ... applica>ons

• automated node failure & network par++on resolu+on

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 41: Beyond the Buzzword - a reactive application in practice

Deployment

• fully managed opera0ons

• auto scalability feature (horizontal & ver0cal)

• a<rac0ve pricing

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 42: Beyond the Buzzword - a reactive application in practice

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 43: Beyond the Buzzword - a reactive application in practice

Load tes)ngSlovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 44: Beyond the Buzzword - a reactive application in practice

Gatling

• open-source load tes0ng framework

• built with Scala, Akka and Ne=y

• two phases: record and run

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 45: Beyond the Buzzword - a reactive application in practice

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 46: Beyond the Buzzword - a reactive application in practice

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))

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 47: Beyond the Buzzword - a reactive application in practice

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 48: Beyond the Buzzword - a reactive application in practice

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 49: Beyond the Buzzword - a reactive application in practice

Bees with machine guns

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 50: Beyond the Buzzword - a reactive application in practice

Configuring all the things

• Installing Python & bees with machine guns

• AWS console (keys, security group w/ SSH access)

• boto config file

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 51: Beyond the Buzzword - a reactive application in practice

Configuring all the things

~/.boto

[Credentials]aws_access_key_id = foobar1aws_secret_access_key = foobar2

[Boto]debug = 2

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 52: Beyond the Buzzword - a reactive application in practice

A"ack!

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu

Page 53: Beyond the Buzzword - a reactive application in practice

Thank you!Ques%ons & Comments ?

• h#p://manuel.bernhardt.io

[email protected]

• @elmanu

Slovak Scala Users' Group May 2016 - manuel.bernhardt.io - @elmanu