2017 02 01 - bluemix chicago meetup - micrsoservices 101

29
Microservices 101 RICK OSOWSKI IBM BLUEMIX CHICAGO MEETUP FEBRUARY 1 ST , 2017

Upload: rick-osowski

Post on 18-Feb-2017

86 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: 2017 02 01 - Bluemix Chicago Meetup - Micrsoservices 101

Microservices 101RICK OSOWSKIIBM BLUEMIX CHICAGO MEETUPFEBRUARY 1ST, 2017

Page 2: 2017 02 01 - Bluemix Chicago Meetup - Micrsoservices 101

AgendaWHAT ARE MICROSERVICESWHY ARE THEY IMPORTANTHOW TO GET STARTEDHOW TO GET THEREQ&A

Page 3: 2017 02 01 - Bluemix Chicago Meetup - Micrsoservices 101

Who am I?

Rick Osowski Senior Technical Staff Member,

Microservices Adoption IBM Cloud Architecture & Solution

Engineering Based here in Chicago! Twitter: @rosowski GitHub: osowski http://osowski.github.io/

Page 4: 2017 02 01 - Bluemix Chicago Meetup - Micrsoservices 101

What are microservices?!?

Page 5: 2017 02 01 - Bluemix Chicago Meetup - Micrsoservices 101

What are microservices?!?

Microservices compose complex distributed applications using “small” independent (autonomous) replaceable processes

that communicate via language-agnostic APIs

which enable agility reliability scalability

Microservice

MicroserviceMicroservice

Microservice

Microservices application

Microservice

Subscribe

REST/HTTP

Microservice

Microservice

broker

API

MicroservicePublish

API

REST/HTTP Publish

ServiceDiscover

y

Page 6: 2017 02 01 - Bluemix Chicago Meetup - Micrsoservices 101

The genesis of the Enterprise Monolith…

Browser IBM HTTP Server DB2

Database

WebSphere ND

WARStore UI

Catalog Service

Cart Service

Search Service

Orders Service

Page 7: 2017 02 01 - Bluemix Chicago Meetup - Micrsoservices 101

Services Registry (WSRR)

Inventory Service Order Service

Search Accounts Carts Orders Billing Products Warehouses

Catalog Service

Efficiency & reuse moved towards SOA…

Page 8: 2017 02 01 - Bluemix Chicago Meetup - Micrsoservices 101

Scale, speed, & strength begot microservices…

• Services manage their own business logic & data stores

• Services access data outside their control through APIs

• Caching used between geographically disparate services

RDBMS

Accounts

Service

RDBMS

Store User

Interface

Recommendation Service Graph

DB

Search Service

Product Details Service

Doc/NoSQL

Orders Service

HadoopShoppin

g Analytics

Cached Calls

Page 9: 2017 02 01 - Bluemix Chicago Meetup - Micrsoservices 101

Comparing our journey…

Microservices Utility compute Infrastructure Assumes component failure Highly Distributed Eventual consistency Compensation flows Difficult to visualise Component autonomy Network complexity

Traditional Enterprise IT High end compute infrastructure Assumes component availability Mostly centralized Consistent data Transactional Easy to understand dependencies Centralized governance Network connected

Page 10: 2017 02 01 - Bluemix Chicago Meetup - Micrsoservices 101

How Teams Work How Apps are

Built

How Apps are Delivered

Page 11: 2017 02 01 - Bluemix Chicago Meetup - Micrsoservices 101

MicroservicesCloud Native

Containers

Page 12: 2017 02 01 - Bluemix Chicago Meetup - Micrsoservices 101

An engineering approach focused on decomposing an application into single-function modules with well defined interfaces which are independently deployed and operated by small teams who own the entire lifecycle of the service.

Microservices accelerate delivery by minimizing communication and coordination between people while reducing the scope and risk of change.

Microservices

Page 13: 2017 02 01 - Bluemix Chicago Meetup - Micrsoservices 101

An application architecture designed to leverage the strengths and accommodate the challenges of a standardized cloud environment, including concepts such as elastic scaling, immutable deployment, disposable instances, and less predictable infrastructure.

Cloud Native

Page 14: 2017 02 01 - Bluemix Chicago Meetup - Micrsoservices 101

A standard way to package an application and all its dependencies so that it can be moved between environments and run without change.

Containers work by hiding the differences between applications inside the container so that everything outside the container can be standardized.

Containers

Page 15: 2017 02 01 - Bluemix Chicago Meetup - Micrsoservices 101

Let’s build some microservices!

Understand the concepts before the technical implementation…

Page 16: 2017 02 01 - Bluemix Chicago Meetup - Micrsoservices 101

Service registration and discovery

Required for load balancing and scaling Services need to find each other Environment changes constantly

Client-side or server-side? Client library, sidecar, or proxy?

Microservice

Microservice

Microservice

ServiceRegistry

Client library

ServiceProxy

app

sidecar

Page 17: 2017 02 01 - Bluemix Chicago Meetup - Micrsoservices 101

Misconception: Microservices and APIs

Microservices are just more fine grained web servicesAPIs are microservices

“micro” refers to the granularity of the components, not the granularity of the exposed interfaces

Monolithic application

Exposed services/APIs

Silocomponent

x 1

x 4

Microservicecomponent

Microservices application

Microservicecomponent

Microservicecomponent

Exposed services/APIs

x 3

x 4

Page 18: 2017 02 01 - Bluemix Chicago Meetup - Micrsoservices 101

Prevent cascading failures

CIRCUIT BREAKER Wrap remote calls Monitor for failures Notify when circuit is tripped

Use with fallback or retries Decide when/how to reset

Client-side concerns: Make requests easy to retry, throttle, and monitor

client circuit breaker service

Page 19: 2017 02 01 - Bluemix Chicago Meetup - Micrsoservices 101

Prevent cascading failures

BULKHEAD Ensure at most n threads waiting for

a slow resource Thread isolation

With or without a queue Timeout / fallback

Semaphore isolation Request sent if lock obtained

client

zippymicroservic

e

slowmicroservic

e

slowmicroservic

e

common thread pool

thread pool

Client-side concerns: Make requests easy to retry, throttle, and monitor

Page 20: 2017 02 01 - Bluemix Chicago Meetup - Micrsoservices 101

Distributed Logging & Tracing

The simplest and most effective debugging tool for a complex microservices web is consistent use of correlation ID’s

Implementing them correctly requires four consistent actions

Create correlation ID if none exists and attach it as a header to every outgoing Service Request

Capture the incoming correlation ID on every incoming request and log it immediately

Attach the correlation ID to the processing of the request (through a threadlocal variable…) and make sure that the same correlation ID is passed on to any downstream requests

Log the correlation id on *any* messages that are connected to that thread of processing

http://opentracing.io provides a vendor-neutral open standard for distributed tracing.

Page 21: 2017 02 01 - Bluemix Chicago Meetup - Micrsoservices 101

Valuable Resources…

Netflix OSS – Eureka, Ribbon, Zuul, Hystrix, etc. https://netflix.github.io/ && https://cloud.spring.io Java-based with robust community support

Amalgam8 – Polyglot-based alternative to the Netflix stack https://www.amalgam8.io/ External sidecar model with centralized routing fabric

Game On – A throwback text-based adventure built to help you explore microservice architectures

https://game-on.org/ Polyglot-based interactive game designed for you to learn and contribute microservices!

Awesome Microservices – A curated list of microservice related principles and technologies https://github.com/mfornos/awesome-microservices

Page 22: 2017 02 01 - Bluemix Chicago Meetup - Micrsoservices 101

How to get there?

Raise your hand if you’re working on existing Enterprise applications…

Page 23: 2017 02 01 - Bluemix Chicago Meetup - Micrsoservices 101

Starting any microservices project…

3 Things…

Understand the Business

Understand the Culture

Understand the Technology

Page 24: 2017 02 01 - Bluemix Chicago Meetup - Micrsoservices 101

Crawl…

Repackage your application Split up your deployable artifacts Apply a single container per service Build, deploy, & manage independently

Refactor your code Existing REST or JMS services? Existing SOAP or EJB services? Servlets or JSPs?

Page 25: 2017 02 01 - Bluemix Chicago Meetup - Micrsoservices 101

Walk…

Refactor your data Isolated islands of data Batch data updates Table denormalization

Page 26: 2017 02 01 - Bluemix Chicago Meetup - Micrsoservices 101

Run…

Iterate, Iterate, Iterate! Macroservices Miniservices Microservices Microservices at scale

Evolving from the named Strangler Pattern

Page 27: 2017 02 01 - Bluemix Chicago Meetup - Micrsoservices 101

Source: http://tech.gilt.com/2014/11/14/making-architecture-work-in-microservice

Monolith Macroservices Microservices Microservices at scale

A Microservices Case Study

• Luxury brands at members-only prices

• Flash sales daily at Noon ET

• Top 50 Internet Retailer• 150 Engineers

2007 2009 2011 2014

Page 28: 2017 02 01 - Bluemix Chicago Meetup - Micrsoservices 101

Questions?!?

Page 29: 2017 02 01 - Bluemix Chicago Meetup - Micrsoservices 101

Thank You!

Please join if you’re not already a member!https://www.meetup.com/bluemix-chicago

Check out my video series on… Microservices for more conversation!https://developer.ibm.com/tv/microservices/

Check out Bluemix for a free trial account to build & play with microservices!https://bluemix.net