taking the friction out of microservice frameworks with lagom

32
@myfear Taking the friction out of microservice frameworks with Lagom Markus Eisele @myfear http://blog.eisele.net http://www.lightbend.com

Upload: markus-eisele

Post on 11-Apr-2017

841 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: Taking the friction out of microservice frameworks with Lagom

@myfear

Taking the friction out of microserviceframeworks with Lagom

Markus Eisele@myfearhttp://blog.eisele.nethttp://www.lightbend.com

Page 2: Taking the friction out of microservice frameworks with Lagom

@myfear

Page 3: Taking the friction out of microservice frameworks with Lagom

@myfear

real-time

consistent experience

always connected

businesscritical

server

snapshot

core localcores distributed

clus

ters

stre

ams

?

Page 4: Taking the friction out of microservice frameworks with Lagom

@myfear

http

://w

ww

.inte

rnet

lives

tats

.com

/inte

rnet

-use

rs/

J2EE

Spring

RoR

Akka

Reactive Manifesto

Microservices

Page 5: Taking the friction out of microservice frameworks with Lagom

@myfear

“We used the right tools to build the wrong things.”

Page 6: Taking the friction out of microservice frameworks with Lagom

@myfear

Rather than acting on data at rest, modern software increasingly operates on data in near

real-time.

Page 7: Taking the friction out of microservice frameworks with Lagom

@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…...

Page 8: Taking the friction out of microservice frameworks with Lagom

@myfear

Page 9: Taking the friction out of microservice frameworks with Lagom

@myfear

“Microservices” is a lousy term

Page 10: Taking the friction out of microservice frameworks with Lagom

@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

Page 11: Taking the friction out of microservice frameworks with Lagom

@myfear

Page 12: Taking the friction out of microservice frameworks with Lagom

@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

Page 13: Taking the friction out of microservice frameworks with Lagom

@myfear

another one?

Page 14: Taking the friction out of microservice frameworks with Lagom

@myfear

“We need to build systems for flexibility and resiliency, not just efficiency and robustness.

Page 15: Taking the friction out of microservice frameworks with Lagom

@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!

Page 16: Taking the friction out of microservice frameworks with Lagom

@myfear

Lagom Persistence

Event Sourcing CQRS

implements leads to

Persistence to CQRS

Page 17: Taking the friction out of microservice frameworks with Lagom

@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

Page 18: Taking the friction out of microservice frameworks with Lagom

@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

Page 19: Taking the friction out of microservice frameworks with Lagom

@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

Page 20: Taking the friction out of microservice frameworks with Lagom

@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

Page 21: Taking the friction out of microservice frameworks with Lagom

@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• …

Page 22: Taking the friction out of microservice frameworks with Lagom

@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

Page 23: Taking the friction out of microservice frameworks with Lagom

@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

Page 24: Taking the friction out of microservice frameworks with Lagom

@myfear

Developer Support

• Run all microservices at once• Embedded Cassandra DB• Intra-service communication via service

locator• Hot reloading

Page 25: Taking the friction out of microservice frameworks with Lagom

@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

Page 26: Taking the friction out of microservice frameworks with Lagom

@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.

Page 27: Taking the friction out of microservice frameworks with Lagom

@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

Page 28: Taking the friction out of microservice frameworks with Lagom

@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

Page 29: Taking the friction out of microservice frameworks with Lagom

@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

Page 30: Taking the friction out of microservice frameworks with Lagom

@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

Page 31: Taking the friction out of microservice frameworks with Lagom

@YourTwitterHandle#DVXFR14{session hashtag} @myfear

Page 32: Taking the friction out of microservice frameworks with Lagom

@YourTwitterHandle#DVXFR14{session hashtag} @myfear