things i wish i'd known before i started with microservices - goto amsterdam 2015

24
Things I wish I'd known before I started with Microservices 1 GOTO Amsterdam - June 18, 2015

Upload: steve-judd

Post on 13-Apr-2017

131 views

Category:

Internet


0 download

TRANSCRIPT

Page 1: Things I wish I'd known before I started with Microservices - GOTO Amsterdam 2015

Things I wish I'd known before I started with Microservices

1

GOTO Amsterdam - June 18, 2015

Page 2: Things I wish I'd known before I started with Microservices - GOTO Amsterdam 2015

Who are we?

2

Steve Judd - Lead ConsultantTareq Abedrabbo - CTO

OpenCredo - an Open Source software consultancy

Page 3: Things I wish I'd known before I started with Microservices - GOTO Amsterdam 2015

Things I wish I'd known before I started with Microservices

What?

Why?

How?

3

Agenda

Page 4: Things I wish I'd known before I started with Microservices - GOTO Amsterdam 2015

What’s the story morning glory?

4

“Gotta have a definition, right?”

Page 5: Things I wish I'd known before I started with Microservices - GOTO Amsterdam 2015

• It is an architecture choice, not a design pattern • Independently deployable software components

(services) • Stateless, loosely coupled, resilient • Communicate via explicit, published APIs • Each service fulfils a single business capability • Automated testing and deployment is essential

5

WHAT

Page 6: Things I wish I'd known before I started with Microservices - GOTO Amsterdam 2015

So, what’s the big deal?

6

Go on, convince me….

Page 7: Things I wish I'd known before I started with Microservices - GOTO Amsterdam 2015

• Encourages: ★ loose-coupling ★ separation of concerns ★ single responsibility principle ★ domain-driven design

• Good fit with Agile development practices • Well-suited to a containerised infrastructure

7

WHY

Page 8: Things I wish I'd known before I started with Microservices - GOTO Amsterdam 2015

8

And are Microservices really the new black?

Monoliths: friend or foe?

Page 9: Things I wish I'd known before I started with Microservices - GOTO Amsterdam 2015

9

Monoliths• Familiar & well-

understood • Easy to develop, build &

deploy • Consequences of

changing domain design are localised

• Limited scaling choices • Long-term commitment to

tech stack (technology lock-in)

Microservices• Flexible scaling options • Enables independence in

development and deployment

• Reduces technology lock-in • Better fault tolerance • Build/deploy/execution

infrastructure is complex (automation a must)

• Getting the domain (service) boundaries right can be difficult

WHY

Page 10: Things I wish I'd known before I started with Microservices - GOTO Amsterdam 2015

10

Monoliths• Familiar & well-

understood • Easy to develop, build &

deploy • Consequences of

changing domain design are localised

• Limited scaling choices • Long-term commitment to

tech stack (technology lock-in)

Microservices• Flexible scaling options • Enables independence in

development and deployment

• Reduces technology lock-in • Better fault tolerance • Build/deploy/execution

infrastructure is complex (automation a must)

• Getting the domain (service) boundaries right can be difficult

WHY

Page 11: Things I wish I'd known before I started with Microservices - GOTO Amsterdam 2015

11

Monoliths• Familiar & well-

understood • Easy to develop, build &

deploy • Consequences of

changing domain design are localised

• Limited scaling choices • Long-term commitment to

tech stack (technology lock-in)

Microservices• Flexible scaling options • Enables independence in

development and deployment

• Reduces technology lock-in • Better fault tolerance • Build/deploy/execution

infrastructure is complex (automation a must)

• Getting the domain (service) boundaries right can be difficult

WHY

Page 12: Things I wish I'd known before I started with Microservices - GOTO Amsterdam 2015

The importance of contracts

12

“Until the contract is agreed, nothing is real”

Page 13: Things I wish I'd known before I started with Microservices - GOTO Amsterdam 2015

• Design your API contracts first • Communicate them well • Use tools to document them, e.g

• apidocjs (http://apidocjs.com/)• swagger (http://swagger.io)• spring-restdocs (https://github.com/spring-projects/spring-restdocs)

• Be mindful of the impact of changing an API

13

HOW

Page 14: Things I wish I'd known before I started with Microservices - GOTO Amsterdam 2015

• If you don’t specify your contract, you end up with an implicit one anyway

• Use the power of resources (HTTP and REST) • Location • Uniform interface • Status codes • Representations

14

HOW

Page 15: Things I wish I'd known before I started with Microservices - GOTO Amsterdam 2015

Does size matter?

15

Provide as many APIs and Services as you need but no more

Page 16: Things I wish I'd known before I started with Microservices - GOTO Amsterdam 2015

• Size - what really matters is quality not quantity • Services should be decoupled conceptually so that

they can evolve independently • Services should be decoupled technically so that they

can be managed independently • What do I do, practically?

• Co-locate services, but avoid implicit dependancies though shared common objects

• Separate services but avoid sharing (domain) libraries

16

HOW

Page 17: Things I wish I'd known before I started with Microservices - GOTO Amsterdam 2015

• Don’t stress about how many APIs or Services • Do stress about designing an appropriate domain models

for your services • Don’t separate your services based on technical

boundaries • Do separate your services based on self-contained

functions

17

HOW

Page 18: Things I wish I'd known before I started with Microservices - GOTO Amsterdam 2015

Separating the men from the boys

18

What does a good microservice look like?

Page 19: Things I wish I'd known before I started with Microservices - GOTO Amsterdam 2015

• Logging & monitoring ✤ Centralised collection ✤ Many more moving parts

• How the services are managed • External configuration • Handling failure • Inter-process communication

✤ Message serialisation/deserialisation ✤ Network overhead

19

HOW

Page 20: Things I wish I'd known before I started with Microservices - GOTO Amsterdam 2015

And finally….

20

Page 21: Things I wish I'd known before I started with Microservices - GOTO Amsterdam 2015

1. Specify your contracts first AND communicate them 2. Design for scale: infrastructure, processes, services 3. You’ll need to pay the Distributed Service Tax 4. Everything is a Service (aka eat your own dogfood) 5. Invest in tooling and automation

21

Final takeaways

Page 22: Things I wish I'd known before I started with Microservices - GOTO Amsterdam 2015

Thank you, any questions?

http://www.opencredo.com/blog @OpenCredo @cyberbliss @tareq_abedrabbo

Page 23: Things I wish I'd known before I started with Microservices - GOTO Amsterdam 2015

Environmental concerns

23

“Infrastructure is much more important than architecture”

Page 24: Things I wish I'd known before I started with Microservices - GOTO Amsterdam 2015

• Allowing more than one service direct access to the same database

• Delaying or ignoring the introduction of good DevOps practices

• Infrastructure management of instances and containers is a challenge

• Performance

24

HOW