taking the friction out of microservice frameworks with lagom
TRANSCRIPT
@myfear
Taking the friction out of microserviceframeworks with Lagom
Markus Eisele@myfearhttp://blog.eisele.nethttp://www.lightbend.com
@myfear
@myfear
real-time
consistent experience
always connected
businesscritical
server
snapshot
core localcores distributed
clus
ters
stre
ams
?
@myfear
http
://w
ww
.inte
rnet
lives
tats
.com
/inte
rnet
-use
rs/
J2EE
Spring
RoR
Akka
Reactive Manifesto
Microservices
@myfear
“We used the right tools to build the wrong things.”
@myfear
Rather than acting on data at rest, modern software increasingly operates on data in near
real-time.
@myfear
Asynchronous, non-blocking, real-time, highly-available, loosely coupled, scalable, fault-tolerant, concurrent, reactive, event-driven, push instead of pull, distributed, low-latency, high throughput…...
@myfear
@myfear
“Microservices” is a lousy term
@myfear
“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
@myfear
@myfear
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
@myfear
another one?
@myfear
“We need to build systems for flexibility and resiliency, not just efficiency and robustness.
@myfear
Not really: Lagom is opinionated!• Use context bounds as boundaries for services!
(Domain Driven Design)• The event log is the book of record!
(Event Sourcing)• Separate the read and write sides!
(CQRS) • Microservices, too, need to be elastic and resilient!
(Reactive)• Developer experience matters!
(The Lagom development setup)• Takes you all the way to production!
@myfear
Lagom Persistence
Event Sourcing CQRS
implements leads to
Persistence to CQRS
@myfear
Read Side
Write Side
Service Interfaces
User views data in the
UIUser makes a change in the
UI
commandquery response
Update data store
changes
CQRS at a glance
@myfear
• We implement our aggregate roots as Persistent Entities
• Persistent Entities will receive commands• Triggered by a command, Persistent
Entities will change their state• Example: Add a friend, remove a friend
Lagom-Services and Persistent Entities
@myfear
• Lagom allows you to scale out by forming a cluster of nodes
• Nodes can be added and removed dynamically
• Lagom allows you to scale out by distributing your Persistent Entities in the cluster
Lagom Cluster
@myfear
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• No object-relational impedance mismatch• Bullet-proof auditing and historical tracing• Support future ways of looking at data• Performance and scalability• Testability
@myfear
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• …
@myfear
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
@myfear
Lagom-Services are Reactive
• Asynchronous I/O • Asynchronous communication as first class• WebSocket support• Reactive Streams support• Distributed by default• Built-on Akka Clustering, Sharding,
Persistence
@myfear
Developer Support
• Run all microservices at once• Embedded Cassandra DB• Intra-service communication via service
locator• Hot reloading
@myfear
Java API Scala API
Client Libraries
Protocols
Programming Model
Kafka Cassandra
JDBC
Service Locator
Service Gateway
Security
Play
JMS
REST
TCP/UDP
File IO
Akka StreamsAkka Persistence
SOAP
Play SOAP
Akka Actors Camel
Spark Streaming
Lagom
RP
Integra-tion
Developer UI / REPL
Akka Cluster
Play JPA / Slick
FTP
SMTP
Integration Technologies
@myfear
• Reactive Microservices Framework for the JVM• Focused on right sized services• Asynchronous I/O and communication as first class
priorities• Highly productive development environment• Takes you all the way to production
Recap.
@myfear
Next Steps! Download and try Lagom!
Project Site:http://www.lightbend.com/lagom
GitHub Repo:https://github.com/lagom
Documentation:http://www.lagomframework.com/documentation/1.0.x/Home.html
Example:https://github.com/typesafehub/activator-lagom-java
@myfear
Written for architects and developers that must quickly gain a fundamental understanding of microservice-based architectures, this free O’Reilly report explores the journey from SOA to microservices, discusses approaches to dismantling your monolith, and reviews the key tenets of a Reactive microservice:
• Isolate all the Things• Act Autonomously• Do One Thing, and Do It Well• Own Your State, Exclusively• Embrace Asynchronous Message-Passing• Stay Mobile, but Addressable• Collaborate as Systems to Solve Problems
http://bit.ly/ReactiveMicroservice
@myfear
The detailed example in this report is based on Lagom, a new framework that helps you follow the requirements for building distributed, reactive systems.
• Get an overview of the Reactive Programming model and basic requirements for developing reactive microservices
• Learn how to create base services, expose endpoints, and then connect them with a simple, web-based user interface
• Understand how to deal with persistence, state, and clients
• Use integration technologies to start a successful migration away from legacy systems
http://bit.ly/DevelopReactiveMicroservice
@myfear
http://bit.ly/SustainableEnterprise
• Understand the challenges of starting a greenfield development vs tearing apart an existing brownfield application into services
• Examine your business domain to see if microservices would be a good fit
• Explore best practices for automation, high availability, data separation, and performance
• Align your development teams around business capabilities and responsibilities
• Inspect design patterns such as aggregator, proxy, pipeline, or shared resources to model service interactions
@YourTwitterHandle#DVXFR14{session hashtag} @myfear
@YourTwitterHandle#DVXFR14{session hashtag} @myfear