microservice come in systems

31
ONE MICROSERVICE IS NO MICROSERVICE THEY COME IN SYSTEMS

Upload: markus-eisele

Post on 11-Apr-2017

200 views

Category:

Technology


0 download

TRANSCRIPT

ONE MICROSERVICEIS NO MICROSERVICETHEY COME IN SYSTEMS

MARKUS EISELE@MYFEAR

[email protected]! "

@Path("/orders/")@Interceptors(CallAudit.class)@Stateless public class OrderService {

@EJB BillingService billing; @EJB DeliveryService delivery; @EJB Warehouse warehouse;

@PUT @Produces({"application/xml","application/json"}) @Consumes({"application/xml","application/json"}) public Order order(Order newOrder){ Order order = warehouse.checkout(newOrder); billing.payForOrder(order); delivery.deliver(order); return order; }

@GET @Path("{orderid}/") @Produces({"application/xml","application/json"}) public Order status(@PathParam("orderid") long orderId){ return delivery.status(orderId); }}

@Path("/orders/")@Interceptors(CallAudit.class)@Stateless public class OrderService {

private Client client; private WebTarget tut;

// ...

@GET @Path("{orderid}/") @Produces({"application/xml","application/json"}) public Order status(@PathParam("orderid") long orderId){ // return delivery.status(orderId); this.client = ClientBuilder.newClient(); this.tut = this.client.target("http://..."); Order order = this.client.target(location).request(MediaType.APPLICATION_XML).get(Order.class); return order; }}

COMPLEX DEPLOYMENT

LARGE TEAMS

BREAKING UP MONOLITHS ADDS COMPLEXITY

BUILDING ONE MICROSERVICE IS GENERALLY EASY.

WHAT IS HARD IS BUILDING A SYSTEM OF MICROSERVICES.

REST - MONOLITH TO MICROSERVICES

REST tends to be our go-to but…> Don’t just do a 1:1 service/interface replacement

> Instead… Design for an asynchronous architecture

Pro-tip: Watch Ben Christensen’s “Don’t build a distributed Monolith” talk from Microservices Practitioner Summit

2016

HOW SHOULD WE BUILD

MICROSERVICE SYSTEMS?

Traditional application architectures

and platforms are obsolete.— Gartner

Architectureand software design principles

matter even more today.— Eisele

ARCHITECTURE PRINCIPLES

> Single Responsible Principle> Service Oriented Architecture

> Encapsulation> Separation of Concern

> Loose Coupling> Hexagonal Architecture

SOFTWARE DESIGN PATTERNS

> Domain-driven Design> Bounded Contexts

> Event Sourcing> CQRS

> Eventual Consistency> Context Maps

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

> Responsive

> Resilient

> Elastic

> Message driven

SCALA, AKKA AND PLAY ARE GREAT FITS HERE

Have a steep learning curveStill a lot to build out yourself

Not explicitly build for microservices

BUT LAGOM IS HERE TO HELP

> Developer experience first!> No ad-hoc scripts to run your

services> Takes you through to production

deployment

WHAT IS IN LAGOM?

> sbt build tool> Scala 2.11 and JDK8

> Play 2.5> Akka 2.4

> Cassandra> Jackson

> Google Guice

HIGHLY OPPINIONATED

> Service API> Persistence API

> Development environment> Production environment

LAGOM SERVICE API

> IO and communication> Streaming between services as a first-class concept

> Higher level of resilience and scalability with no blocking

> Service is a Bounded Context in DDD> Service Clients & Endpoints

LAGOM PERSISTENCE API

> Event sourced (deltas) with Cassandra backend by default

> No object/relational impedance mismatch> Can always replay to determine current state> Allows you to learn more from your data later> Persistent entity is an Aggregate Root in DDD

> Can be overridden for CRUD if you want

DEVELOPMENT ENVIRONMENT$ cd my-first-system$ activator... (booting up)> runAll[info] Starting embedded Cassandra server..........[info] Cassandra server running at 127.0.0.1:4000[info] Service locator is running at http://localhost:8000[info] Service gateway is running at http://localhost:9000[info] Service helloworld-impl listening for HTTP on 0:0:0:0:0:0:0:0:24266[info] Service hellostream-impl listening for HTTP on 0:0:0:0:0:0:0:0:26230(Services started, use Ctrl+D to stop and go back to the console...)

NEXT STEPS FOR LAGOM

> Scala API> Swagger integration

> Maven support> Support for more DBs

> Integration with other cluster orchestration tools

> … What is missing?

REACTIVE MICROSERVICES ARCHITECTURE

BIT.LY/REACTIVEMICROSERVICE

> explore a microservice architecture> based on Reactive principles

> for building an isolated service that’s

> scalable, resilient to failure,> and combines with other services

> to form a cohesive whole

DEVELOPING REACTIVE MICROSERVICES

HTTP://BIT.LY/DEVELOPREACTIVEMICROSERVICE

> create base services, expose endpoints, and then connect them

with a simple, web-based user interface

> deal with persistence, state, and clients

> Use integration technologies to start a successful migration away

from legacy systems

NEXT STEPS

Project Site:http://www.lightbend.com/lagom

GitHub Repo:https://github.com/lagom

Documentation:http://www.lagomframework.com/documentation/1.0.x/

Home.html

❕ ❓