scala –wo machtder einsatzsinn?€¦ · was verstehe ich unter microservices? domain (firma,...
TRANSCRIPT
![Page 1: Scala –wo machtder EinsatzSinn?€¦ · Was verstehe ich unter Microservices? Domain (Firma, Tätigkeitsfeld) Subdomain Quelle: ImplementingDDD, Vaughn](https://reader036.vdocuments.pub/reader036/viewer/2022063008/5fbe36dda46220503705c28b/html5/thumbnails/1.jpg)
Speaker:
Scala – wo macht der Einsatz Sinn?am Berner Architekten Treffen
Mario Siegenthaler
23.06.2017
![Page 2: Scala –wo machtder EinsatzSinn?€¦ · Was verstehe ich unter Microservices? Domain (Firma, Tätigkeitsfeld) Subdomain Quelle: ImplementingDDD, Vaughn](https://reader036.vdocuments.pub/reader036/viewer/2022063008/5fbe36dda46220503705c28b/html5/thumbnails/2.jpg)
linkyard
Continuous Delivery Testing Identity und Access
![Page 3: Scala –wo machtder EinsatzSinn?€¦ · Was verstehe ich unter Microservices? Domain (Firma, Tätigkeitsfeld) Subdomain Quelle: ImplementingDDD, Vaughn](https://reader036.vdocuments.pub/reader036/viewer/2022063008/5fbe36dda46220503705c28b/html5/thumbnails/3.jpg)
Soll ich
Microservices
in
Scala
implementieren?
(und wenn ja: welche?)
![Page 4: Scala –wo machtder EinsatzSinn?€¦ · Was verstehe ich unter Microservices? Domain (Firma, Tätigkeitsfeld) Subdomain Quelle: ImplementingDDD, Vaughn](https://reader036.vdocuments.pub/reader036/viewer/2022063008/5fbe36dda46220503705c28b/html5/thumbnails/4.jpg)
Was verstehe ich unter Microservices?
Domain (Firma, Tätigkeitsfeld)Quelle: Implementing DDD, Vaughn
![Page 5: Scala –wo machtder EinsatzSinn?€¦ · Was verstehe ich unter Microservices? Domain (Firma, Tätigkeitsfeld) Subdomain Quelle: ImplementingDDD, Vaughn](https://reader036.vdocuments.pub/reader036/viewer/2022063008/5fbe36dda46220503705c28b/html5/thumbnails/5.jpg)
Was verstehe ich unter Microservices?
Domain (Firma, Tätigkeitsfeld)
Subdomain
Quelle: Implementing DDD, Vaughn
![Page 6: Scala –wo machtder EinsatzSinn?€¦ · Was verstehe ich unter Microservices? Domain (Firma, Tätigkeitsfeld) Subdomain Quelle: ImplementingDDD, Vaughn](https://reader036.vdocuments.pub/reader036/viewer/2022063008/5fbe36dda46220503705c28b/html5/thumbnails/6.jpg)
Was verstehe ich unter Microservices?
Domain (Firma, Tätigkeitsfeld)
Subdomain
BoundedContext
BoundedContext
BoundedContext
BoundedContext
BoundedContext
Quelle: Implementing DDD, Vaughn
![Page 7: Scala –wo machtder EinsatzSinn?€¦ · Was verstehe ich unter Microservices? Domain (Firma, Tätigkeitsfeld) Subdomain Quelle: ImplementingDDD, Vaughn](https://reader036.vdocuments.pub/reader036/viewer/2022063008/5fbe36dda46220503705c28b/html5/thumbnails/7.jpg)
Was verstehe ich unter Microservices?
Domain (Firma, Tätigkeitsfeld)
Subdomain
BoundedContext
BoundedContext
BoundedContext
BoundedContext
BoundedContext
Micro-Service
Micro-Service
Micro-Service
Micro-Service
Micro-Service
Quelle: Implementing DDD, Vaughn
![Page 8: Scala –wo machtder EinsatzSinn?€¦ · Was verstehe ich unter Microservices? Domain (Firma, Tätigkeitsfeld) Subdomain Quelle: ImplementingDDD, Vaughn](https://reader036.vdocuments.pub/reader036/viewer/2022063008/5fbe36dda46220503705c28b/html5/thumbnails/8.jpg)
Was verstehe ich unter Microservices?
Domain (Firma, Tätigkeitsfeld)
Subdomain
Monolith
Nano
![Page 9: Scala –wo machtder EinsatzSinn?€¦ · Was verstehe ich unter Microservices? Domain (Firma, Tätigkeitsfeld) Subdomain Quelle: ImplementingDDD, Vaughn](https://reader036.vdocuments.pub/reader036/viewer/2022063008/5fbe36dda46220503705c28b/html5/thumbnails/9.jpg)
Was verstehe ich unter Microservices?
BoundedContext
BoundedContext
BoundedContext
BoundedContext
BoundedContext
Micro-Service
Micro-Service
Micro-Service
Micro-Service
Micro-Service
!
"
#
![Page 10: Scala –wo machtder EinsatzSinn?€¦ · Was verstehe ich unter Microservices? Domain (Firma, Tätigkeitsfeld) Subdomain Quelle: ImplementingDDD, Vaughn](https://reader036.vdocuments.pub/reader036/viewer/2022063008/5fbe36dda46220503705c28b/html5/thumbnails/10.jpg)
Welche Technologie für welchen Microservice?
BoundedContext
BoundedContext
BoundedContext
BoundedContext
BoundedContext
![Page 11: Scala –wo machtder EinsatzSinn?€¦ · Was verstehe ich unter Microservices? Domain (Firma, Tätigkeitsfeld) Subdomain Quelle: ImplementingDDD, Vaughn](https://reader036.vdocuments.pub/reader036/viewer/2022063008/5fbe36dda46220503705c28b/html5/thumbnails/11.jpg)
Scala für Microservices
BoundedContext
Scala
![Page 12: Scala –wo machtder EinsatzSinn?€¦ · Was verstehe ich unter Microservices? Domain (Firma, Tätigkeitsfeld) Subdomain Quelle: ImplementingDDD, Vaughn](https://reader036.vdocuments.pub/reader036/viewer/2022063008/5fbe36dda46220503705c28b/html5/thumbnails/12.jpg)
Scala ist eine sichere Wahl
$
% &
'
scalacenter
#11
![Page 13: Scala –wo machtder EinsatzSinn?€¦ · Was verstehe ich unter Microservices? Domain (Firma, Tätigkeitsfeld) Subdomain Quelle: ImplementingDDD, Vaughn](https://reader036.vdocuments.pub/reader036/viewer/2022063008/5fbe36dda46220503705c28b/html5/thumbnails/13.jpg)
Die Vorteile von Scala
f(x)funktional
Performance stabiler Betrieb
lesbar%
immutability(
Tooling)
stark typsicher*
mächtig∠
JVM JavaScript
![Page 14: Scala –wo machtder EinsatzSinn?€¦ · Was verstehe ich unter Microservices? Domain (Firma, Tätigkeitsfeld) Subdomain Quelle: ImplementingDDD, Vaughn](https://reader036.vdocuments.pub/reader036/viewer/2022063008/5fbe36dda46220503705c28b/html5/thumbnails/14.jpg)
Lesbarkeit durch kompakten Syntax
case class Name(firstName: String, lastName: String)
val mario = Name(“Mario“, “Siegenthaler“)val mario2 = mario.copy(lastName = “Goechnaths“)
%
![Page 15: Scala –wo machtder EinsatzSinn?€¦ · Was verstehe ich unter Microservices? Domain (Firma, Tätigkeitsfeld) Subdomain Quelle: ImplementingDDD, Vaughn](https://reader036.vdocuments.pub/reader036/viewer/2022063008/5fbe36dda46220503705c28b/html5/thumbnails/15.jpg)
Die Vorteile von Scala
f(x)funktional
Performance stabiler Betrieb
lesbar%
immutability(
Tooling)
stark typsicher*
mächtig∠
JVM JavaScript
![Page 16: Scala –wo machtder EinsatzSinn?€¦ · Was verstehe ich unter Microservices? Domain (Firma, Tätigkeitsfeld) Subdomain Quelle: ImplementingDDD, Vaughn](https://reader036.vdocuments.pub/reader036/viewer/2022063008/5fbe36dda46220503705c28b/html5/thumbnails/16.jpg)
keine Reflection & keine Codegenerierung
case class User(id: Long, name: String, roles: Set[String])
val json = “{id: 123, name: ‘Mario‘, roles: [‘admin‘, ‘user‘]}“
val user = decode[User](json)// Either[Error, User] = Right(User(123, “Mario“, ...)
Bibliothek:https://circe.github.io/circe/
∠
![Page 17: Scala –wo machtder EinsatzSinn?€¦ · Was verstehe ich unter Microservices? Domain (Firma, Tätigkeitsfeld) Subdomain Quelle: ImplementingDDD, Vaughn](https://reader036.vdocuments.pub/reader036/viewer/2022063008/5fbe36dda46220503705c28b/html5/thumbnails/17.jpg)
Die Vorteile von Scala
f(x)funktional
Performance stabiler Betrieb
lesbar%
immutability(
Tooling)
stark typsicher*
mächtig∠
JVM JavaScript
![Page 18: Scala –wo machtder EinsatzSinn?€¦ · Was verstehe ich unter Microservices? Domain (Firma, Tätigkeitsfeld) Subdomain Quelle: ImplementingDDD, Vaughn](https://reader036.vdocuments.pub/reader036/viewer/2022063008/5fbe36dda46220503705c28b/html5/thumbnails/18.jpg)
Die Vorteile von Scala
f(x)funktional
Performance stabiler Betrieb
lesbar%
immutability(
Tooling)
stark typsicher*
mächtig∠
JVM JavaScript
![Page 19: Scala –wo machtder EinsatzSinn?€¦ · Was verstehe ich unter Microservices? Domain (Firma, Tätigkeitsfeld) Subdomain Quelle: ImplementingDDD, Vaughn](https://reader036.vdocuments.pub/reader036/viewer/2022063008/5fbe36dda46220503705c28b/html5/thumbnails/19.jpg)
Vorschlag für Einsatz
BoundedContext
BoundedContext
BoundedContext
BoundedContext
BoundedContext
Scala
Scala
![Page 20: Scala –wo machtder EinsatzSinn?€¦ · Was verstehe ich unter Microservices? Domain (Firma, Tätigkeitsfeld) Subdomain Quelle: ImplementingDDD, Vaughn](https://reader036.vdocuments.pub/reader036/viewer/2022063008/5fbe36dda46220503705c28b/html5/thumbnails/20.jpg)
Klassische Architektur mit Skalierungsproblemen
Quelle: https://www.slideshare.net/jboner/from-microliths-to-microsystems
Microlith
Single Instance
SQL
REST
Service
JPA
![Page 21: Scala –wo machtder EinsatzSinn?€¦ · Was verstehe ich unter Microservices? Domain (Firma, Tätigkeitsfeld) Subdomain Quelle: ImplementingDDD, Vaughn](https://reader036.vdocuments.pub/reader036/viewer/2022063008/5fbe36dda46220503705c28b/html5/thumbnails/21.jpg)
Lösung: ereignisbasiertes Domain Driven Design(Event-Sourcing)
Command
Aggregate
Event
![Page 22: Scala –wo machtder EinsatzSinn?€¦ · Was verstehe ich unter Microservices? Domain (Firma, Tätigkeitsfeld) Subdomain Quelle: ImplementingDDD, Vaughn](https://reader036.vdocuments.pub/reader036/viewer/2022063008/5fbe36dda46220503705c28b/html5/thumbnails/22.jpg)
Alles basiert auf Ereignissen
Process Manager(Saga)
Read Model
![Page 23: Scala –wo machtder EinsatzSinn?€¦ · Was verstehe ich unter Microservices? Domain (Firma, Tätigkeitsfeld) Subdomain Quelle: ImplementingDDD, Vaughn](https://reader036.vdocuments.pub/reader036/viewer/2022063008/5fbe36dda46220503705c28b/html5/thumbnails/23.jpg)
Integration über Ereignisse
![Page 24: Scala –wo machtder EinsatzSinn?€¦ · Was verstehe ich unter Microservices? Domain (Firma, Tätigkeitsfeld) Subdomain Quelle: ImplementingDDD, Vaughn](https://reader036.vdocuments.pub/reader036/viewer/2022063008/5fbe36dda46220503705c28b/html5/thumbnails/24.jpg)
Immutable
Funktional
Bessere Isolation Domain
Mächtige Process Models
Actors mit Akka
Gute Gelegenheit(Paradigmenwechsel)
Scala passt optimal dazu
![Page 25: Scala –wo machtder EinsatzSinn?€¦ · Was verstehe ich unter Microservices? Domain (Firma, Tätigkeitsfeld) Subdomain Quelle: ImplementingDDD, Vaughn](https://reader036.vdocuments.pub/reader036/viewer/2022063008/5fbe36dda46220503705c28b/html5/thumbnails/25.jpg)
Wann Event-first-DDD anwenden?
Komplexe Business
LogikAbläufe
über Zeit oder
zwischen Systemen
Hohe Last (lesend &
mutierend)
Integration mit Machine
Learning
![Page 26: Scala –wo machtder EinsatzSinn?€¦ · Was verstehe ich unter Microservices? Domain (Firma, Tätigkeitsfeld) Subdomain Quelle: ImplementingDDD, Vaughn](https://reader036.vdocuments.pub/reader036/viewer/2022063008/5fbe36dda46220503705c28b/html5/thumbnails/26.jpg)
Für welche Microservices ist Scala gut?
BoundedContext
BoundedContext
BoundedContext
BoundedContext
BoundedContext
Scala
Scala
![Page 27: Scala –wo machtder EinsatzSinn?€¦ · Was verstehe ich unter Microservices? Domain (Firma, Tätigkeitsfeld) Subdomain Quelle: ImplementingDDD, Vaughn](https://reader036.vdocuments.pub/reader036/viewer/2022063008/5fbe36dda46220503705c28b/html5/thumbnails/27.jpg)
Einsatzgebiet: Analytics
, , , ,
![Page 28: Scala –wo machtder EinsatzSinn?€¦ · Was verstehe ich unter Microservices? Domain (Firma, Tätigkeitsfeld) Subdomain Quelle: ImplementingDDD, Vaughn](https://reader036.vdocuments.pub/reader036/viewer/2022063008/5fbe36dda46220503705c28b/html5/thumbnails/28.jpg)
Einsatzgebiet: Analytics
, , , ,
- Performant
- Deklarativ
- Mathematische Notationen abbildbar
- Typsicher
![Page 29: Scala –wo machtder EinsatzSinn?€¦ · Was verstehe ich unter Microservices? Domain (Firma, Tätigkeitsfeld) Subdomain Quelle: ImplementingDDD, Vaughn](https://reader036.vdocuments.pub/reader036/viewer/2022063008/5fbe36dda46220503705c28b/html5/thumbnails/29.jpg)
Fazit
Scala für Kernkomponenten oder hoher Last
Scala für Data Science und Machine Learning
Idiomatisch nutzen: Funktional, Immutable, Typsystem
Prüfen: Events statt RPC/REST für Integration
![Page 30: Scala –wo machtder EinsatzSinn?€¦ · Was verstehe ich unter Microservices? Domain (Firma, Tätigkeitsfeld) Subdomain Quelle: ImplementingDDD, Vaughn](https://reader036.vdocuments.pub/reader036/viewer/2022063008/5fbe36dda46220503705c28b/html5/thumbnails/30.jpg)