microservices are not worth the trouble..?? · microservices reinforce modular structure,...

57
Why you should take a deep breath and think about it before you decide you should use a Microservices architecture 1 MICROSERVICES ARE NOT WORTH THE TROUBLE..??

Upload: others

Post on 20-May-2020

21 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

Why you should take a deep breath and think about it before you decide you should use a Microservices architecture

1

MICROSERVICES ARE NOT WORTH THE TROUBLE..??

Page 2: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

JAMES BIRNIE

● James Birnie, lead consultant @ ThoughtWorks since June 2015

● http://www.jamesbirnie.com/● [email protected]● Worked at a startup for 9 years● Worked in software since 1996

Page 3: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

A Global Community of TechnologistsAbout ThoughtWorks

Page 4: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices
Page 5: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

Croatia v England, 19:00 BST

Page 6: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

Service alterations, buses will replace trains No longer wish to travel,

entitled to a full refund

Page 7: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices
Page 8: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices
Page 9: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices
Page 10: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

Clementine’s Cat

Indifference...

Schrodinger’s Cat

Page 11: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

Indifferent

Aloof

StandoffishArrogant Disinterested

Detached DistantUnresponsive

Page 12: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

MICROSERVICES ARE NOT WORTH THE TROUBLE!!??

● Key Benefits of Microservices

● Complexity and where it lives

● Important Outcomes

● Microservices Trade-offs

● Outcomes based Case Studies

● Top tips for Microservices success

Page 13: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

What will a Microservices architecture give me that I won’t get from a monolithic application?

13

THE MICROSERVICES PROMISES

Page 14: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

KEY MICROSERVICES BENEFITS...

● Reduction of handovers and communication taxes○ Make Conway’s Law work FOR you

● Independent scalability of components● Independent codebases and releases● Components should be reduced in complexity● Technology diversity● System downtime can be reduced● They can enable platform thinking

Page 15: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

The minimum required complexity in any system is fixed. Architectural choices can therefore only optimise or move this complexity.

15

WHERE IS MY COMPLEXITY?

Page 16: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

COMPLEXITY OF A MONOLITHIC SYSTEM...

● 5 “Things” in the system

● Means up to 4 + 3 + 2 + 1 = 10 possible connections

● You have added 5 more possible connections

● Add one more “thing” to the system

● N “things” will have N(N - 1) / 2 possible connections

● For example 16 “things” will have 120 possible connections

Page 17: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

REDUCE COMPLEXITY WITH MICROSERVICES…??

● 16 “things” have 120 possible connections

● Group together related “things” into contexts

● Only allow connections between related “things” or between contexts

● In this example the maximum number of connections is now reduced to 31

3

6

6

10

6

Page 18: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

HANG ON…. SOMETHING IS MISSING HERE…?

Page 19: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

HANG ON…. SOMETHING IS MISSING HERE…?

● Would all the “things” really connect to all the other “things”?

○ Wouldn’t it make sense, with or without Microservices, to only connect to related things?

● There may be multiple connections between different contexts

● What other complexity may be introduced?

Page 20: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

COMPLEXITY HAS MOVED...

● Your Microservices components should be small enough to understand and reason with

● BUT, complexity has moved…○ Orchestration between components is now necessary○ It will be much harder to reason with and debug your

program logic○ You will have more, and more complex, tests○ You will have more builds○ You will have more technologies in play○ You will have a much bigger monitoring

and maintenance overhead

Page 21: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

Microservices is a solution but too often it is invoked early and becomes an end, and hence a problem statement, in and of itself.

21

WHAT OUTCOMES ARE IMPORTANT?

Page 22: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

HANDOVERS ARE BAD, LET’S REDUCE HANDOVERS...

1 - Intra team, empathetic handover

2 - Aligned team, sympathetic handover

3 - Transactional handover, no alignment, no empathy, no sympathy

Page 23: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

NO TEAM SHOULD BLOCK ANY OTHER TEAM’S RELEASE

● Split the monolithic code base by contexts○ A carefully designed monolith will help with this

● Consider not splitting data contexts○ There may still be tensions over shared assets○ Databases can be logically segregated

● There might be a co-ordination overhead● Applications can be deployed

to the same servers

Page 24: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

INDEPENDENT SCALABILITY OF COMPONENTS

● One size doesn’t always fit all but how important is it REALLY?

○ Will the management cost outweigh the benefit?● Infrastructure management tools that

provide better abstractions could help● You can scale app servers independently

that access a common datastore

Page 25: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

STRONG MODULE BOUNDARIES ARE DESIRABLE

● Microservices reinforce modular structure, particularly important for large teams

● Microservices are decoupled by definition● Microservices can get Conway’s Law working in

your favour● Monoliths can also have good modular

structure but it is harder to enforce

Page 26: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

Nothing in the world comes for free. What are the key trade offs that we have to consider before we use a Microservices architecture?

26

SO WHAT ARE THE DOWNSIDES?

Page 27: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

THE MICROSERVICES PREMIUM

● https://martinfowler.com/bliki/MicroservicePremium.html● Automated deployment● Monitoring● Dealing with failure● Eventual Consistency● Developer complexity● Complexity of service to service communication

○ Protocols and patterns○ Certificates, firewalls, all the THINGS!

Page 28: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

IF THINGS AREN’T DONE WELL YOU MAY FIND...

● Releases need to be coordinated● Many different solutions to the same problems emerge

throughout your business● Funding must be product based or your infrastructure

could decay● Conway’s law can work for you or against

you - you may create different silos

Page 29: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

Not every solution delivers what you want. Sometimes you can get into a bit of a mess with all the best intentions...

29

WHAT CAN GO WRONG SOMETIMES

Page 30: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

SUBOPTIMAL MICROSERVICES PLATFORM IMPLEMENTATION

● Inconsistent product vision● Requirements constantly pivoting● Technology based microservices● Poor attention to maintainability● Immature devops practice● Waterfall funding● Inconsistent implementations● Strange technology choices

Page 31: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

WHAT WE WERE DOING TO HELP TO IMPROVE THIS SITUATION

● Upskilling teams to instill a DevOps style “you build it, you run it” culture

● Fought hard to assign budgets to products● Redesigned microservices to more closely align with

business capabilities● Aligning teams around the services

Page 32: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

Some solutions I’ve worked on or come across that helped deliver the Microservices promises without all of the associated overheads.

32

SOME OUTCOMES BASED SOLUTIONS

Page 33: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

ALLOW TEAMS TO DEPLOY INDEPENDENTLY OF ONE ANOTHER...

● Enterprise solution in a startup that had evolved over a number of years

● As the company grew it became increasingly hard to coordinate releases across teams

● Monolithic solution with some services and Winforms applications consuming services

● Single relational database● Infrastructure in a managed

data centre

Page 34: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

EVOLVED SOLUTION

MONOLITHIC RELATIONAL DATABASE

MONOLITHIC WEB APPLICATION

SOAP SERVICES

INTERNAL APPS

Page 35: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

EVOLVED SOLUTION

MONOLITHIC RELATIONAL DATABASE

MONOLITHIC WEB APPLICATION

SOAP SERVICES

INTERNAL APPS

TECH TEAMS

WEB

TOOLS

INFRA

DB

BUSINESS TEAMS

SALES

PARTNERS

CS

CONTENT

MARKETING

Page 36: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

HOW WE MOVED TO A BETTER PLACE...

● Code was refactored into assemblies● Shared assemblies, representing cross cutting

concerns, were made into packages● Codebase was split vertically to more accurately

mirror business divisions● Software teams became cross functional

aligned to a business vertical● Database remained monolithic● Infrastructure was largely unchanged

Page 37: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

PLANNED SOLUTION TO ALLOW INDEPENDENT CODE RELEASES

MONOLITHIC RELATIONAL DATABASE

MONOLITHIC WEB APPLICATION

SOAP SERVICES

INTERNAL APPS

TECH TEAMS

WEB

TOOLS

INFRA

DB

BUSINESS TEAMS

SALES

PARTNERS

CS

CONTENT

MARKETING

MONOLITHIC RELATIONAL DATABASE DB

E-COMMERCE CSPARTNERSHIPSSUPPLY CONTENT

FRONT ENDS

SERVICES

FRONT ENDS

SERVICES

FRONT ENDS

SERVICES

FRONT ENDS

SERVICES

FRONT ENDS

SERVICES

Page 38: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

THE OUTCOME...

● WE ACHIEVED…○ Separation of codebases allowing independent code releases○ A closer alignment between business units and the teams

delivering value to them

● WE DIDN’T ACHIEVE…○ Separate scalability of components○ Bounded data contexts

● WE AVOIDED…○ Managing eventual consistency○ Introducing extra developer complexity

Page 39: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

TRYING TO BUST SILOS

● Publishing company refreshing its product offering● Attempting to leverage a platform created for the new

US market application● Many silos existed in the content creation space

centred on technology centric outcomes● It was taking an estimated 13+ months to deliver new

value to the product

Page 40: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

WORKING THROUGH ENDLESS SILOS

40

I want to configure SOMETHING to subscribe to X and store data in THE

STORE

Page 41: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

ENDLESS SILOS

RAW DOCUMENT

ABOUT 15 SILOED

PROCESSES

DOCUMENT DATABASE

CONTENT PRODUCTION

APPLICATIONS TEAMS

ENHANCED DOCUMENT

SHARED DISPLAY

SERVICES

US APP UK APP

Page 42: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

A PRODUCT LED APPROACH

● We were initially asked to analyse the content enhancement process

● All silos knew exactly what their piece did but had little visibility of the overall picture

● We started asking product based questions● We simplified the content production process and owned

the whole outcome● Cycle time was reduced to days

Page 43: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

OWNING THE WHOLE OUTCOME

RAW DOCUMENT

ABOUT 15 SILOED

PROCESSES

DOCUMENT DATABASE

ENHANCED DOCUMENT SHARED

DISPLAY SERVICES

US APP UK APP

RAW DOCUMENT

PRODUCT FOCUSSED

ENHANCEMENT

PRODUCT SPECIFIC

‘MICROSERVICE’

PRODUCT DISPLAY SERVICE

CYCLE TIME REDUCED TO DAYS

Page 44: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

● WE ACHIEVED…○ Shorter cycle times by removing the need to traverse silos○ Separate scalability by deploying to separate virtual servers○ A greater understanding of customer focus

● HOWEVER...○ We imposed a greater requirement on our team

to manage deployments○ We reengineered rather than reused code○ We had to monitor and support

our components

THE OUTCOME...

Page 45: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

Microservices are a great tool to deliver some great outcomes. But they come with a cost. Understand the outcomes you want and ask if you can sustain the cost.

45

SO WHEN SHOULD WE USE MICROSERVICES?

Page 46: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

TIP #5: YOU CAN START WITH A MONOLITH

● Design it well, it will be easier to break up● You can deliver outcomes one by one

○ Split the code bases and use libraries○ Find a way to deploy pieces separately○ Split your teams when the bounded contexts emerge

● Many successful Microservices implementations started as monoliths

● Think about scale - Microservices really start to pay off at scale

Page 47: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

TIP #4: UNDERSTAND THE COST OF MICROSERVICES

● Business needs to understand the ongoing cost of maintenance of the system

● You will need to invest in developer experience● Monitoring and alerting may need improvement● Understand how to deal with failure● Eventual consistency must be managed

Page 48: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

TIP #3: YOU NEED STRONG TECHNICAL LEADERSHIP

● The technical direction needs to be consistent● The tech leadership needs to be backed by a long term

committed business● Follow conventions and document your

design decisions ● Committed advocates for the

architecture will help

Page 49: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

TIP #2: UNDERSTAND WHAT OUTCOMES YOU WANT

● Ask yourself “If Microservices is the answer, what is the question”

● Clearly understand the outcomes you need● You don’t have to go “full” Microservices to deliver

desirable outcomes● Understand what good looks like

Page 50: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

TIP #1: MICROSERVICES ARE GREAT - WHEN DONE WELL!

● You have to be this tall to use Microservices!● You will need a high devops maturity● Make sure you have buy in at all appropriate levels● Product thinking and customer focus will go a long way

to making Microservices a success

Page 51: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

SOME USEFUL BOOKS...

Page 52: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

Please feel free to come and talk to me after the session if you want a more involved answer or just fancy a chat!

52

ANY QUESTIONS?

Page 53: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

OTHER PREREQUISITES

● IS THERE SOMETHING IN THE FUNDING MODEL TO ANSWER HERE? DOES WATERFALL FUNDING MEAN THAT IT WILL BE HARD TO MAINTAIN A GOOD MICROSERVICES INFRASTRUCTURE?

● HOW CAN YOU PROPERLY SEGREGATE THE DIFFERENT TEAMS AND PARTS OF THE SYSTEM?● AT SLC WE HAVEN’T PROPERLY SEGREGATED THINGS● MATURITY OF PRODUCT OWNERSHIP● PRODUCT THINKING - SERVICES AS PRODUCTS● TENSION BETWEEN HOW FEATURES ARE DELIVERED AND HOW THEY CONSUME CAPABILITY● THIS IS RESOLVABLE BY GOOD PRODUCT THINKING

Page 54: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

OTHER OUTCOMES THAT CAN BE FACILITATED?

● Maybe more of a reason to use Microservices - it enables platform thinking. But is this a good thing without product focus?

Page 55: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

EVOLVED SOLUTION BEFORE MANAGED CHANGE

MONOLITHIC RELATIONAL DATABASE

MONOLITHIC WEB APPLICATION

SOAP SERVICES

INTERNAL APPS

TECH TEAMS

WEB

TOOLS

INFRA

DB

BUSINESS TEAMS

SALES

PARTNERS

CS

CONTENT

MARKETING

Page 56: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices

PLANNED SOLUTION TO ALLOW INDEPENDENT CODE RELEASES

MONOLITHIC RELATIONAL DATABASE DB

E-COMMERCE CSPARTNERSHIPSSUPPLY CONTENT

FRONT ENDS

SERVICES

FRONT ENDS

SERVICES

FRONT ENDS

SERVICES

FRONT ENDS

SERVICES

FRONT ENDS

SERVICES

Page 57: MICROSERVICES ARE NOT WORTH THE TROUBLE..?? · Microservices reinforce modular structure, particularly important for large teams Microservices are decoupled by definition Microservices