41
Think Small To Go Big An Introduction To Microservices By: Ryan Baxter @ryanjbaxter http://ryanjbaxter.com 3/11/15

Think Small To Go Big - Introduction To Microservices

Embed Size (px)

Citation preview

Think Small To Go Big – An

Introduction To Microservices

By: Ryan Baxter

@ryanjbaxter

http://ryanjbaxter.com

3/11/15

We Have A Need For Speed

1

Agile Meant Speed

2

….but we couldn’t deploy fast enough

3

Now We Have DevOps

4

….but getting infrastructure takes too long

5

The Cloud Made Infrastructure Easy

6

…but our apps were not built for the cloud

7

Infrastructure That Is Out Of Our

Control

9

Unprecedented Scale

10

How Did We Solve This Problem

Before?

11

Scaling Horizontally Is Cheaper

12

We End Up With Something Like This

13

Load Balancer

Different Platforms

14

Requires A New Way Of Thinking

Our old application designs just can’t keep up

Massive monolithic applications break down under

these new challenges

15

We Need A New Architecture

Applications that are composed of smaller more

focused “micro” apps

16

What is a Microservice?

“In short, the microservice architectural style is an

approach to developing a single application as a suite of

small services, each running in its own process and

communicating with lightweight mechanisms, often an

HTTP resource API.” - Martin Fowler

17

It’s Not All About The Code

18

Guidelines For Microservices

Make each one focused – no real rule on size

“2 pizza teams”

Each service should be treated like one app

Have its one SCM repo, own pipeline, etc

Should not require the use of other services

Service owners are responsible for the entire lifecycle

Use lightweight protocols

Use the right tool for the job

19

Guidelines For Microservices

Each service should have its own datastore

Failure will happen, design for it

Automate everything

20

Isn’t This Just SOA?

Hot topic, they are certainly very similar and try to

solve the same problem

SOA was always considered very heavy

ESBs

Driven by vendors

SOA allowed for monoliths

SOA was more about reuse than team organization and

application architecture

21

Benefits Of Microservices

Code for each service is easier to understand

Small code base means more speed

Each service can be deployed independently

Failures do not bring down the whole app

Technology flexibility

Easier to evolve

Well defined APIs

22

Cons Of Microservices

Complexity

You have to manage multiple apps

Deploying 1 feature may involve coordination between multiple

services

Performance – multiple service calls

When to switch to microservices

Dev tools focus on monolithic apps

Duplication of code

End To End Testing

23

DEMO

24

Monolith Architecture

25

Client Side Code

App

Sessions APIs

Questions APIs

Twilio Endpoint

DB

SMS/Email Service

Failures In A Monolith

26

Client Side Code

App

Sessions APIs

Questions APIs

Twilio Endpoint

DB

SMS/Email Service

Scaled Monolith

27

My App 1

DB

Client Side Code

App

Sessions API

Twilio Endpoint

Questions API

Load Balancer

My App 1

SMS/Email Service

Client Side Code

App

Sessions API

Twilio Endpoint

Questions API

SMS/Email Service

Microservices Architecture

28

Client Side Code

Sessions Service

Questions Service

Reply Service

Twilio Service

SendGrid Service

Sessions DB

Questions DB

MessageQueue

Client Fragility

29

Client Side Code

Sessions Service

Questions Service

Reply Service

Twilio Service

SendGrid Service

Sessions DB

Questions DB

MessageQueue

API Gateways

30

Sessions Service

Questions Service

Reply Service

Twilio Service

SendGrid Service

Sessions DB

Questions DB

MessageQueue

API Gateway

Client Side Code

Scaling A Service

31

Sessions Service

Questions Service

Reply Service

Twilio Service

SendGrid Service

Sessions DB

Questions DB

MessageQueue

Sessions Service

API Gateway

Client Side Code

Service Discovery

33

Sessions ServiceQuestions Service

Reply Service

Twilio Service

SendGrid Service

Sessions DBQuestions DB

MessageQueue

Sessions Service

API Gateway

Client Side Code

Service Discover

y

Service Discovery

Eureka – Neflix OSS Component

Zookeeper – Apache Project

Consul

34

Circuit Breakers

35

DEMO

36

Containers/Docker

Is a great deployment and

isolation tool for your

microservices

Allows your microservices to

run on various clouds

Need to use some kind of

container management tool to

orchestrate, monitor, and scale

your microservices

37

Platform-as-a-Service

Deploying a large scale distributed set of apps requires

a lot of effort (even if you are using Docker)

A platform-as-a-service can make it somewhat easier

Built in monitoring, recovery, and scaling can really go

a long way

Deployments are also much easier because you just

provide the code

Take a look at any Cloud Foundry based PaaS

38

Deploying Microservices With Cloud

Foundry Easy as cf push appname –p <jar file>

Or use Cloud Foundry Maven or Gradle plugin

You can use blue/green deployments to make sure you

have no downtime during deploys

Each microservice can be used as a Cloud Foundry

service to facilitate service discovery

Built-in load balancer can help with dynamic scaling

Everything can be automated so it all happens on

commit

39

Netflix

The poster child for microservices

They have a great set of open source

libraries in the Neflix OSS project

Service Discovery, Circuit Breakers,

Service To Service Communication,

and much much more…

Check out Spring Cloud if you are a

Spring user, very easy to integrate

Netflix OSS into your apps

40

Transitioning To Microservices

42

Thank you.