decoupled apis through microservices

58
MICROSERVICES DECOUPLING API S THROUGH David Simons @SwamWithTurtles

Upload: david-simons

Post on 13-Apr-2017

259 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Decoupled APIs through Microservices

M I C R O S E R V I C E SD E C O U P L I N G A P I S T H R O U G H

David Simons @SwamWithTurtles

Page 2: Decoupled APIs through Microservices

M I C R O S E R V I C E SD E C O U P L I N G A P I S T H R O U G H

David Simons @SwamWithTurtles

Page 3: Decoupled APIs through Microservices

W H O A M I ?

• David Simons (@SwamWithTurtles)

• Freelance Tech Lead/Consultant

• Hacker specialising in Node and Java

Page 4: Decoupled APIs through Microservices

M Y E X P E R I E N C E W I T H A P I S

• Focused on web development

• Utilise data from our own, or third party APIs to affect rendered data

Page 5: Decoupled APIs through Microservices

W H AT I W A N T T O TA L K A B O U T…

• What problems do microservices solve?

• What is a microservice?

• An example!

• When are microservices wrong?

• How can I start implementing microservices?

Page 6: Decoupled APIs through Microservices

W H AT P R O B L E M S D O M I C R O S E R V I C E S S O LV E ?

Q U E S T I O N 1 :

Page 7: Decoupled APIs through Microservices

W H AT D O W E A S P I R E F O R I N A G O O D A P I ?

Page 8: Decoupled APIs through Microservices

W H AT M A K E S A G O O D A P I ?

HATEOS-y

Sensibly named

Ignorant of ConsumersWell Maintained

Tested

Appropriate

Extensible

Hard to Misuse

Secure Useful

High Quality Data

RESTful

Easy to Adopt

Resilient

Performant

Versioned Declarative

Flexible output formats

Stable

Well Documented

Page 9: Decoupled APIs through Microservices

D E C O U P L E D

A G O O D A P I I S …

Page 10: Decoupled APIs through Microservices

R E U S A B L E

A G O O D A P I I S …

Page 11: Decoupled APIs through Microservices

S C A L A B L E

A G O O D A P I I S …

Page 12: Decoupled APIs through Microservices

A M I C R O S E R V I C E A R C H I T E C T U R E M A K E S

Y O U R A P I S M O R E :

D E C O U P L E D , R E U S A B L E A N D S C A L A B L E

M Y C L A I M …

Page 13: Decoupled APIs through Microservices

W H AT I S A M I C R O S E R V I C E ?

Q U E S T I O N 2 :

Page 14: Decoupled APIs through Microservices

Independently deployable services focused around business concerns,

which contain all your logic.

Page 15: Decoupled APIs through Microservices

F O C U S E D A R O U N D B U S I N E S S C O N C E R N S

M I C R O S E R V I C E S A R E …

Page 16: Decoupled APIs through Microservices

M I C R O S E R V I C E S A R E N O T L AY E R E D A R C H I T E C T U R E S

B AT C H D ATA P R O C E S S

D ATA A C C E S S L AY E R

P R E S E N TAT I O N T I E R

M E S S A G E Q U E U E

Page 17: Decoupled APIs through Microservices

B U S I N E S S C O N C E R N S

B AT C H D ATA P R O C E S S

D ATA A C C E S S L AY E R

P R E S E N TAT I O N T I E R

TaxPricing

Page 18: Decoupled APIs through Microservices

I N D E P E N D E N T LY D E P L O YA B L E

M I C R O S E R V I C E S A R E …

Page 19: Decoupled APIs through Microservices

B U S I N E S S C O N C E R N S

B AT C H D ATA P R O C E S S

D ATA A C C E S S L AY E R

P R E S E N TAT I O N T I E R

TaxPricing

Page 20: Decoupled APIs through Microservices

B U S I N E S S C O N C E R N S

B AT C H D ATA P R O C E S S

D ATA A C C E S S L AY E R

P R E S E N TAT I O N T I E R

Tax v2Pricing

Page 21: Decoupled APIs through Microservices

T H E F R A C T U R E D M O N O L I T H

B E WA R E …

Page 22: Decoupled APIs through Microservices

C O N TA I N I N G A L L Y O U R L O G I C

A M I C R O S E R V I C E H A S …

Page 23: Decoupled APIs through Microservices

- M A R T I N F O W L E R

“Smart Endpoints, Dumb Pipes”

Page 24: Decoupled APIs through Microservices

S M A R T P I P E S

Page 25: Decoupled APIs through Microservices

H O W D O E S T H I S M AT C H O U R “ I D E A L A P I ” ?

Page 26: Decoupled APIs through Microservices

D E C O U P L E D

• Implementation can’t be leaked due to separate deployments

• Corollary: Microservice architectures can be polyglot

• All the intelligence is in the system

Page 27: Decoupled APIs through Microservices

R E U S A B L E

• Services contain “just enough” information to be useful in multiple places

• No danger of long strands of dependencies

Page 28: Decoupled APIs through Microservices

S C A L A B L E

• Separate systems can each be deployed independently of the other

• Smaller systems have less requirements in terms of hardware

Page 29: Decoupled APIs through Microservices

A N E X A M P L E !

Page 30: Decoupled APIs through Microservices
Page 31: Decoupled APIs through Microservices

• Youth-targeted BBC news site

• Targeting a range of devices

• Needing to deal with a large amount of traffic and spikes

Page 32: Decoupled APIs through Microservices

S 3

N E W S B E AT ‘ M I C R O S E R V I C E ’ A R C H I T E C T U R E

B B C C O N T E N T S E R V I C E S

F R O N T- E N D F E T C H & D I S P L AY

L B SQSR E N D E R E R S

Page 33: Decoupled APIs through Microservices

• Robust

• Encapsulated and Decoupled

• Extensible

Page 34: Decoupled APIs through Microservices

W H AT ’ S T H E D O W N S I D E ?

Q U E S T I O N 3 :

Page 35: Decoupled APIs through Microservices

M I C R O S E R V I C E S A R E N O T R I G H T F O R E V E RY O N E

WA R N I N G

Page 36: Decoupled APIs through Microservices

M O R E R E Q U E S T S

• Increased latency

• Less suitable for mobile platforms

Page 37: Decoupled APIs through Microservices

M O R E C O M P L E X

• Upfront costs in terms of set-up and maintenance

• Architecture can be more complex

• Issues are less discoverable

Page 38: Decoupled APIs through Microservices

C O S T

• Added complexity

• Repeated licensing costs for non-open source platforms

Page 39: Decoupled APIs through Microservices

B U T…

• Similar issues exist with any “encapsulation” methodology:

• OOP

• Web Components

Page 40: Decoupled APIs through Microservices

H O W C A N I S TA R T T O I M P L E M E N T T H E M ?

Q U E S T I O N 4 :

Page 41: Decoupled APIs through Microservices

T H E R E ’ S T O O M U C H T O TA L K A B O U T I N O N E TA L K .

WA R N I N G

Page 42: Decoupled APIs through Microservices

C R E AT I O N

S T E P # 1 :

Page 43: Decoupled APIs through Microservices

C R E AT I O N

• Do it yourself!

• Lightweight languages such as NodeJS make API creation easy

• App creation frameworks like Spring Boot (Java) and Yeomen (JS)

Page 44: Decoupled APIs through Microservices

C R E AT I O N

• DropWizard

Page 45: Decoupled APIs through Microservices

C R E AT I O N

• Automated API Generation

• e.g. Swagger, Strongloop

Page 46: Decoupled APIs through Microservices

P O P U L AT I O N

S T E P # 2 :

Page 47: Decoupled APIs through Microservices

J U S T C O D E I T !

P O P U L A T I O N

Page 48: Decoupled APIs through Microservices

T H I N G S C A N B E H A R D E R

B U T…

Page 49: Decoupled APIs through Microservices

S O W H E R E D O W E F O C U S ?

• Security

• Greater documentation

• Integration testing

Page 50: Decoupled APIs through Microservices

A L S O T E A M C H A N G E

• “organizations which design systems ... are constrained to produce designs which are copies of the communication structures of these organizations"

• - Conway’s Law

Page 51: Decoupled APIs through Microservices

M E S S A G E PA S S I N G

S T E P # 3 :

Page 52: Decoupled APIs through Microservices

M E S S A G E PA S S I N G

• “Smart Endpoints, Dumb Pipes” - Martin Fowler

• All the standard ways of consuming APIs - e.g. HTTP, Message Queues

Page 53: Decoupled APIs through Microservices

D E P L O Y M E N T

S T E P # 4 :

Page 54: Decoupled APIs through Microservices

D E P L O Y M E N T

• Five years ago:

• Work hard

Page 55: Decoupled APIs through Microservices

D E P L O Y M E N T

• Automate it as much as possible

• Old favourites: Continuous Integration/Source Control

• Puppet/Chef for config management

• Docker can automate microservice containers

Page 56: Decoupled APIs through Microservices

T O C O N C L U D ES O …

Page 57: Decoupled APIs through Microservices

T O C O N C L U D E …

• APIs work best when they allow separate parts of your system to behave independently

• Using microservices can enforce this pattern

• The Ecosystem is big - and growing!

Page 58: Decoupled APIs through Microservices

T H A N K S

@swamwithturtles swamwithturtles.com