reactive microservices lutz huehnken @lutzhuehnken http ... · sign-on service adressbook payment...
TRANSCRIPT
![Page 1: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/1.jpg)
Lutz Huehnken@lutzhuehnken
http://www.reactivesystems.eu
Reactive Microservices
![Page 2: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/2.jpg)
Traditional application architectures and platforms are obsolete. Anne Thomas, Gartner Modernizing Application Architecture and Infrastructure Primer for 2016.
January 29, 2016
![Page 3: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/3.jpg)
Why talk about Lagom?Just one framework, but quite inspiring. A „gateway drug“ to
• Reactive Systems • Event Sourcing & CQRS • Domain-Driven Design
![Page 4: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/4.jpg)
Microservices
![Page 5: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/5.jpg)
The microservice architectural style is an approach to developing a single application as a suite of small services, each running in its own process. Martin Fowler
![Page 6: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/6.jpg)
Microservice Trade-offs
Again, according to Mr. Martin Fowler
• Distribution • Eventual Consistency • Operational Complexity
![Page 7: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/7.jpg)
Microservice Trade-offs
• Distributed systems are harder to program, since remote calls are slow and are always at risk of failure.
• Maintaining strong consistency is extremely difficult for a distributed system, which means everyone has to manage eventual consistency.
![Page 8: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/8.jpg)
Microservice Trade-offs
• You need a mature operations team to manage lots of services, which are being redeployed regularly.
![Page 9: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/9.jpg)
All this hype about microservices makes me sad. And not about the concept, but about the name. As I wrote before, “micro” in “microservices” means absolutely nothing. What is worse, it confuses everybody. Again and again I see people focusing on “micro” and falling into nanoservices trap. Eugene Kalenkovich
![Page 10: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/10.jpg)
Lagom (pronounced [ˈlɑ̀ːɡɔm]) is a Swedish word meaning "just the right amount". The Lexin Swedish-English dictionary defines lagom as "enough, sufficient, adequate, just right". https://en.wikipedia.org/wiki/Lagom
![Page 11: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/11.jpg)
The ideas in Eric Evan’s Domain-Driven Design are very useful to us in finding sensible boundaries for our services. Sam Newman, „Building Microservices“, p. 38
![Page 12: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/12.jpg)
Service Boundaries
UserService ?
Credentials
AdressBook
Payment Data
![Page 13: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/13.jpg)
Single Responsibility Principle BrokenUserService ?
Credentials
AdressBook
Payment Data
Order History
Reviews
Credit Score
Marketing Profile
![Page 14: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/14.jpg)
Bounded Contexts
Sign-On Service
AdressBook
Payment Data
Order History
Reviews
Credit Score
Marketing Profile
![Page 15: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/15.jpg)
Different Levels of Abstraction
![Page 16: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/16.jpg)
Actor Model• Everything is an actor • Each actor has an address • When an actor handles a
message, it can • create new actors • send messages to other
actors • change the behavior for
handling the next message
ActorModel
![Page 17: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/17.jpg)
Akka
ActorModel
Akka(incl.Cluster,…)
Akka is a toolkit and runtime for building highly concurrent, distributed, and resilient message-driven applications on the JVM.
![Page 18: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/18.jpg)
Akka StreamsAn intuitive and safe way to formulate stream processing setups such that we can then execute them efficiently and with bounded resource usage.
ActorModel
Akka(incl.Cluster,…)
Streams
![Page 19: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/19.jpg)
LagomA framework for creating microservice-based systems
ActorModel
Akka(incl.Cluster,…)
Streams
![Page 20: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/20.jpg)
Example: The Service API
![Page 21: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/21.jpg)
„Service“ as a first-class concept
• Service Descriptors abstract from transport • Services have a typed interface • Can be treated like objects, can be injected etc. • Service Client includes Service Lookup, Circuit
Breaker
![Page 22: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/22.jpg)
public interface HelloService extends Service { ServiceCall<NotUsed, String, String> sayHello(); ... }
interface ServiceCall<Id, Request, Response> { CompletionStage<Response> invoke(Id id, Request request); } Async
„Service“ as a first-class concept
![Page 23: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/23.jpg)
ServiceCall<NotUsed, Source<String, ?>, Source<String, ?>> sayHello();
Not strict, but a stream (materialized as WebSocket)
Built-in support for asynchronous streaming
![Page 24: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/24.jpg)
Developer Experience
![Page 25: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/25.jpg)
• Run all microservices at once
• Embedded Cassandra DB
• Embedded Kafka Message Bus
• Inter-service communication via service locator
• Hot reloading
Development tooling
![Page 26: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/26.jpg)
Lagom Persistence
![Page 27: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/27.jpg)
A Rail-Guided Approach
• A guided approach to Event Sourcing and CQRS • Required structure provides clarity and simplicity • Cassandra given as default data store • ReadSideProcessor provided for read side
![Page 28: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/28.jpg)
Lagom Persistence
Lagom Persistence
Event Sourcing
CQRSimplements leads to
Not covered: More Domain Driven Design, NoSQL Databases
![Page 29: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/29.jpg)
• We implement our aggregates as PersistentEntities
• PersistentEntities will receive commands
• Triggered by a command, PersistentEntities will change their state
• Example: Add a friend, remove a friend
FriendEntity
Peter
Bob
Alice
Aggregates
![Page 30: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/30.jpg)
FriendEntity
Peter
Bob
Alice
Memory Image
• We keep all* our PersistentEntities in memory!
• We have now moved from a CRUD approach to a Memory Image approach
• See http://martinfowler.com/bliki/MemoryImage.html
(*) or a working set, entities will be passivated and activated as needed
![Page 31: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/31.jpg)
• Lagom allows you to scale out by distributing your PersistentEntities in the cluster (Cluster Sharding)
Node A
Lagom Cluster
Node B
Node C
XBobAlice
Z
XY
PaulPeter
![Page 32: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/32.jpg)
• Lagom allows you to scale out by forming a cluster of nodes
• Nodes can be added and removed dynamically
Node A
Lagom Cluster
Node B
Node C
Node Djoin
![Page 33: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/33.jpg)
• But how does our data survive a system crash?
• We log all the state changes!
Node A
Lagom Persistence
Node B
Node C
XBobAlice
Z
XY
PaulPeter
![Page 34: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/34.jpg)
Event Sourcing - storing deltas
• Every state change is materialized in an Event
• All events are stored in an Event Log • Current state is constructed by replaying
all events
![Page 35: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/35.jpg)
Event Sourcing - Storing Deltas
UserCreated (Alice)
Friend Added (Bob)
Friend Added (Peter)
Friend Removed(Bob)
![Page 36: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/36.jpg)
Traditional Way
User(Alice)
Friend (Peter)
Friend (Bob)
![Page 37: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/37.jpg)
Event Sourcing - benefits
• No object-relational impedance mismatch • Bullet-proof auditing and historical
tracing • Support future ways of looking at data • Performance and scalability • Testability
![Page 38: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/38.jpg)
Persistent Entity
DataStore(e.g.CassandraCluster)
FriendService
YPeter
FriendService
XBobAlice FriendService
YXY
![Page 39: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/39.jpg)
Event Sourcing - Snapshots
1 2 100 101 102 103..
Snapshot
![Page 40: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/40.jpg)
Event Sourcing with Lagom Persistence
• Keep all data in memory! • Optional: Only working set, by using passivation/
activation
• Store all state changes as events • Replay all events of an actor to recreate it
• Optional: Start from snapshot
• Scale out with Lagom Cluster and scalable data store
![Page 41: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/41.jpg)
Read-Side
UserCreated(Alice)
FriendAdded(Bob)
FriendAdded(Peter)
Alice
Bob
Peter
Alice
Bob
X
Y
![Page 42: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/42.jpg)
Read-Side
UserCreated(Alice)
FriendAdded(Bob)
FriendAdded(Peter)
FOLLOWERSuserid followedby
BobAliceBobXBobYPeterAlice
![Page 43: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/43.jpg)
Read side is derived from event log
• Events forwarded to read side to build different representations
• ElasticSearch • SQL, de-normalized • Stream Processor / Analytics • BI • OLAP • …
![Page 44: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/44.jpg)
Read side cont’d
• Read side can be discarded and re-created.
• The „book of record“ is the event log. • Read side can be scaled out by creating
copies - it’s read only.
• Btw, you can get a status for an identified entity on the write side, too.
![Page 45: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/45.jpg)
Consistency
FOLLOWERSuserid followedby
BobAliceBobXBobYPeterAlice
DataStore(e.g.CassandraCluster)
Alice1 - Actor
2 - Journal / Event Store
3 - Read Side
![Page 46: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/46.jpg)
Consistency
Alice1 - Actor
• A Persistent Entities defines an Aggregate Root
• Aggregate Root is the Transactional Boundary
• Strong consistency within an Aggregate Root
• Commands are executed sequentially on the latest state
• No limit to scalability
![Page 47: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/47.jpg)
Consistency
DataStore(e.g.CassandraCluster)
2 - Journal / Event Store
• Depending on implementation / configuration
• Popular choice: Cassandra • „Tunable Consistency“ • Proper use of quorum ensures
consistency
![Page 48: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/48.jpg)
Consistency
FOLLOWERSuserid followedby
BobAliceBobXBobYPeterAlice
3 - Read Side
• Will not be updated immediately, but deferred
• Not much different from queries in interactive applications
![Page 49: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/49.jpg)
Event Sourcing with Lagom Persistence revisited
• Keep all data in memory! • Store all state changes as events • Replay all events of an actor to recreate it • Strong consistency for Actor (aggregate)
and Journal • Eventual Consistency for Read Side
![Page 50: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/50.jpg)
Event Sourcing might not be right for everything
• In this case, don’t use Lagom Persistence • You can use whatever data store you like • Beware of blocking APIs (JDBC..) • For Cassandra, you can use the
CassandraSession from the Persistence module
![Page 51: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/51.jpg)
Resilience
![Page 52: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/52.jpg)
Reactive
![Page 53: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/53.jpg)
• Asynchronous I/O
• Asynchronous communication as first class
• Reactive Streams over WebSockets support
• Message Bus (based on Kafka)
Reactive
![Page 54: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/54.jpg)
• Distributed by default
• Built-on Akka Clustering, Sharding, Persistence
• Circuit-Breaker Pattern built-in
Reactive
![Page 55: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/55.jpg)
Resilience
Based on Akka Cluster
• „Node Ring“ with Gossip protocol • No Single Point of Failure, no Master • Nodes can leave / join dynamically • Network partition handling
![Page 56: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/56.jpg)
Authority..
Service 1
Service 2
Service 3
Service 4
Service 5?
?
??
![Page 57: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/57.jpg)
vs. Autonomy
Service 1
Service 2
Service 3
Service 4
Service 5
![Page 58: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/58.jpg)
Don’t Ask, Tell
Communication patterns in Microservices
• Query • Event
By providing a messaging API (and an embedded message bus in development) Lagom encourages the „autonomy“ (event-based) approach.
![Page 59: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/59.jpg)
Without resilience, nothing else matters. If your beautiful, production-grade, elastic, scalable, highly concurrent, non-blocking, asynchronous, highly responsive and performant application isn’t running, then you’re back to square one. It starts and ends with resilience. Jonas Bonér, CTO
![Page 60: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/60.jpg)
Operations
![Page 61: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/61.jpg)
Deployment
• Create bundles (or Docker images) with a single command
• Needs orchestration tool that provides Service Locator and supports Akka Cluster (node discovery).
• ConductR (commercial product) works seemlessly, open source projects for etcd, ZooKeeper, Consul, go to these for Kubernetes, Docker Swarm..
![Page 62: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/62.jpg)
• Getting started: lightbend.com/lagom
• Examples: lightbend.com/activator/templates
• Contribute: https://github.com/lagom
• Communicate:
• https://groups.google.com/forum/#!forum/lagom-framework
• https://gitter.im/lagom/lagom
• Lightbend Proof of Concept Program: lightbend.com/company/contact
Try it out
![Page 63: Reactive Microservices Lutz Huehnken @lutzhuehnken http ... · Sign-On Service AdressBook Payment Data Order History Reviews Credit Score Marketing Profile. Different Levels of Abstraction](https://reader033.vdocument.in/reader033/viewer/2022042219/5ec568040e30496ba6458729/html5/thumbnails/63.jpg)
Read this book
https://www.lightbend.com/reactive-microservices-architecture
(free, registration required)