SlideShare ist ein Scribd-Unternehmen logo
1 von 34
Downloaden Sie, um offline zu lesen
Microservices
The Best Practices
20.11.2018 | Pavel Micka
About Me
• Pavel Mička
• Software architect at ZOOM International
• Modernizing CallRecording and WorkForce
Optimization application
• Previously: Software engineer at Cisco
Systems
• Breaking up monolith, I helped to build
• pavel.micka@zoomint.com
• @pavelmicka_xyz
The Monolith
Monolith - advantages
• Default architectural style
• Whole application in one piece
• One deployable artifact
• Easy to distribute
• All data in one place
• Doing cross-selects is trivial
• Strong consistency model
• Extremely good processing latency
• There is no network…
Monolith - drawbacks
• Increasingly hard to maintain/evolve
• Internal parts tightly coupled (interdependencies)
• Technological monoculture
• Hard to start/setup
• A lot of dependencies
• Hard to scale independently
• Hard to assign clear responsibilities
• Usually ends up in Big Ball of Mud
• HA is often problematic (shared state)
“If you have only a hammer, everything looks as a nail”
Microservices
Microservice architecture
• Separately deployable
• Built around bounded context
• Vertical slice of functionality
• Size: 2 pizza team
• Internals are opaque
• Services separated using API
Microservices – advantages
• Fast release cycle
• Each service may be written using different technology
• Are small
• Extremely resilient, if written properly
• Microservice architecture scales well
• You can scale the technology by feature
• More important: you can scale the TEAM
Drawbacks: There is no silver bullet
• Do not do microservices, if you have
• Just started with the project
• Legacy product without fast development
• Limited automation
• Slow release cycle & Waterfall
• Small number of developers
• Low latency requirements
• Low memory requirements
Showcase service
Audit Log
The “showcase” service
• Audit log
• Used for compliance reasons
• Logs all user actions
• All user actions must be logged
• This is real production code
• Basic tech facts
• Java 8/11
• Spring Boot
• Built using Gradle
• Artifact: RPM
Best practices
Automate, automate, automate
Work Organization
Westrum Culture Model
Implement DevOps
• Take care of the full lifecycle
• Create GIT repo
• Create build pipeline
• Build the code
• Test it
• Get it to distribution
• Distribute it
• Maintain it
• Microservices are about agility & rapid delivery
• If you need an external team for everything, you will not be very agile…
Describe you data model
• What are the entities in your business?
• Formalize them
• What properties/relations do they have?
• How they fulfil the business use case?
• How do you want to expand your model from business perspective?
• Regardless if you are 10 years on the market, perform this
exercise…
• You may find out that you current model contains contradictions
• And/Or does not fully satisfy the needs of your customers
Standardize
&
Automate
Standardize quality & testing
• Use latest versions of libraries
• OWASP/Continuous security is a good vehicle
• Other teams are easily able to help, when scenarios are covered
by tests
• Tests are easily executable without exotic setup
• Consider: TestContainers
• Do not: run tests against “database in lab”
Standardize Versioning
• Use semantic versioning (1.3.2)
• Only visible API is versioned
• Patch == No change in API (bugfixes, new libs…)
• Minor == Additive change in API
• Major == Something was removed/modified
• Pitfalls
• Change in interpretation is breaking (timestamp in ms vs. ns)
• If you rewrite JS to Cobol, but keep API, its just a patch change
Technical practices
Create a paved path
• Using Spring Boot is just the start
• Create opinionated chassis
Build in resiliency
• Because of network you cannot distinguish:
• Request was lost on the way
• Request failed during processing
• Response failed
• Request or response are still on their way
• Request/response can though a different network line
• Slow request causes cascading failures
• Use bulkheads
• Use circuit breakers
Use Bulkheads
Bulkheads in software
Build is also a code
• Build is also a code
• Gradle & Maven: use plugins
• Continuous integration: use templates
Example
• apply plugin: ‘quality-plugin’
• Coverage, PMD, Checkstyle, licenses, reports, OWASP
• Build of RPM or Docker should be also a one-liner
• Preconditon: all projects have the same structure
Use integration tests
• Integration tests == testing the component as a whole, DB included
• Unit Tests: You have unit tested app & its security in isolation
• Performing integration tests suite should be relatively cheap
• The service surface is small
• Gives you sense of security that its really works
• You still need a unit test suite
Avoid N+1 scenarios
• 2 services (one handling users, other logs)
• Load N users, load logs for each one separately
• May somehow work in a single transaction
• BUT if logs and users are in different microservice, it will not work
• You will tend to implement caches (hint: don’t)
• Implement multiget
Observability: Monitoring and Logging
• Centralized monitoring
• Have an overview of all state of all services in one place
• Use TVs in your office for dashboards (if you are a cloud company)
• Centralized logging
• Have log messages in one place (you want to correlate)
• Its not fun to search the flow through 7 services, each with 3 instances
• Distributed tracing
• Be able to track your request across many services
What about consistency?
• With microservices you get eventual consistency
• Eventually the system will end up in consistent state
• Heavy use of queues
• Idempotent operations
• Strong consistency via distributed transactions?
• Creates more issues than is really solves
• Its expensive
• Some error states need to be manually resolved in 2 phase commit
Eventually consistent delete
• Delete agent and all his logs
• Message cannot be lost
• If delete from customer db fails
• The message was not ACKed
• The same applies to billing
• This is choreography based
• Other option: orchestration
Questions
&
Answers

Weitere ähnliche Inhalte

Was ist angesagt?

ITECH Kenya presentation on OpenMRS Developers Forum
ITECH Kenya presentation on OpenMRS Developers ForumITECH Kenya presentation on OpenMRS Developers Forum
ITECH Kenya presentation on OpenMRS Developers Forum
djazayeri
 

Was ist angesagt? (20)

Sdn not just a buzzword
Sdn not just a buzzwordSdn not just a buzzword
Sdn not just a buzzword
 
Reactive Web Development with Spring Boot 2
Reactive Web Development with Spring Boot 2Reactive Web Development with Spring Boot 2
Reactive Web Development with Spring Boot 2
 
Introduce flux & react in practice
Introduce flux & react in practiceIntroduce flux & react in practice
Introduce flux & react in practice
 
OpenMRS Reference Application, Getting Started
OpenMRS Reference Application, Getting StartedOpenMRS Reference Application, Getting Started
OpenMRS Reference Application, Getting Started
 
Automation in Network Lifecycle Management - Bay Area Juniper Meetup
Automation in Network Lifecycle Management - Bay Area Juniper MeetupAutomation in Network Lifecycle Management - Bay Area Juniper Meetup
Automation in Network Lifecycle Management - Bay Area Juniper Meetup
 
The 7 deadly sins of micro services
The 7 deadly sins of micro servicesThe 7 deadly sins of micro services
The 7 deadly sins of micro services
 
Management Data Warehouse
Management Data WarehouseManagement Data Warehouse
Management Data Warehouse
 
Using Chat Automation - ChatOps
Using Chat Automation - ChatOpsUsing Chat Automation - ChatOps
Using Chat Automation - ChatOps
 
Essential git for developers
Essential git for developersEssential git for developers
Essential git for developers
 
Spring Batch Introduction (and Bitbucket Project)
Spring Batch Introduction (and Bitbucket Project)Spring Batch Introduction (and Bitbucket Project)
Spring Batch Introduction (and Bitbucket Project)
 
Taskflow
TaskflowTaskflow
Taskflow
 
GeekOut 2017 - Microservices in action at the Dutch National Police
GeekOut 2017 -  Microservices in action at the Dutch National PoliceGeekOut 2017 -  Microservices in action at the Dutch National Police
GeekOut 2017 - Microservices in action at the Dutch National Police
 
What is this agile thing anyway
What is this agile thing anywayWhat is this agile thing anyway
What is this agile thing anyway
 
ITECH Kenya presentation on OpenMRS Developers Forum
ITECH Kenya presentation on OpenMRS Developers ForumITECH Kenya presentation on OpenMRS Developers Forum
ITECH Kenya presentation on OpenMRS Developers Forum
 
Making the Transition from the Suite to the Hub
Making the Transition from the Suite to the HubMaking the Transition from the Suite to the Hub
Making the Transition from the Suite to the Hub
 
ONAP on Vagrant
ONAP on VagrantONAP on Vagrant
ONAP on Vagrant
 
Scalable game-servers-tgc
Scalable game-servers-tgcScalable game-servers-tgc
Scalable game-servers-tgc
 
Embracing DevOps through database migrations with Flyway
Embracing DevOps through database migrations with FlywayEmbracing DevOps through database migrations with Flyway
Embracing DevOps through database migrations with Flyway
 
Architecture - December 2013 - Avinash Ramineni, Shekhar Veumuri
Architecture   - December 2013 - Avinash Ramineni, Shekhar VeumuriArchitecture   - December 2013 - Avinash Ramineni, Shekhar Veumuri
Architecture - December 2013 - Avinash Ramineni, Shekhar Veumuri
 
Modern Module Development
Modern Module DevelopmentModern Module Development
Modern Module Development
 

Ähnlich wie Microservices: The Best Practices

Ähnlich wie Microservices: The Best Practices (20)

Microservices: Yes or not?
Microservices: Yes or not?Microservices: Yes or not?
Microservices: Yes or not?
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
 
Reactive Micro Services with Java seminar
Reactive Micro Services with Java seminarReactive Micro Services with Java seminar
Reactive Micro Services with Java seminar
 
Architectural Decisions: Smoothly and Consistently
Architectural Decisions: Smoothly and ConsistentlyArchitectural Decisions: Smoothly and Consistently
Architectural Decisions: Smoothly and Consistently
 
Architectural Decisions: Smoothly and Consistently
Architectural Decisions: Smoothly and ConsistentlyArchitectural Decisions: Smoothly and Consistently
Architectural Decisions: Smoothly and Consistently
 
Make It Cooler: Using Decentralized Version Control
Make It Cooler: Using Decentralized Version ControlMake It Cooler: Using Decentralized Version Control
Make It Cooler: Using Decentralized Version Control
 
QCon 2015 - Microservices Track Notes
QCon 2015 - Microservices Track Notes QCon 2015 - Microservices Track Notes
QCon 2015 - Microservices Track Notes
 
Deploying at will - SEI
 Deploying at will - SEI Deploying at will - SEI
Deploying at will - SEI
 
Microservice Architecture
Microservice ArchitectureMicroservice Architecture
Microservice Architecture
 
Microservice intro
Microservice introMicroservice intro
Microservice intro
 
DevOps Days Ohio
DevOps Days OhioDevOps Days Ohio
DevOps Days Ohio
 
The Rocky Cloud Road
The Rocky Cloud RoadThe Rocky Cloud Road
The Rocky Cloud Road
 
Microservices Architecture
Microservices ArchitectureMicroservices Architecture
Microservices Architecture
 
All about that reactive ui
All about that reactive uiAll about that reactive ui
All about that reactive ui
 
Itsummit2015 blizzard
Itsummit2015 blizzardItsummit2015 blizzard
Itsummit2015 blizzard
 
Software Architecture and Architectors: useless VS valuable
Software Architecture and Architectors: useless VS valuableSoftware Architecture and Architectors: useless VS valuable
Software Architecture and Architectors: useless VS valuable
 
Devoxx PL 2018 - Microservices in action at the Dutch National Police
Devoxx PL 2018 - Microservices in action at the Dutch National PoliceDevoxx PL 2018 - Microservices in action at the Dutch National Police
Devoxx PL 2018 - Microservices in action at the Dutch National Police
 
Iot cloud service v2.0
Iot cloud service v2.0Iot cloud service v2.0
Iot cloud service v2.0
 
Why retail companies can't afford database downtime
Why retail companies can't afford database downtimeWhy retail companies can't afford database downtime
Why retail companies can't afford database downtime
 
How to grow your own Microservice?
How to grow your own Microservice?How to grow your own Microservice?
How to grow your own Microservice?
 

Kürzlich hochgeladen

%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 

Kürzlich hochgeladen (20)

%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 

Microservices: The Best Practices

  • 1.
  • 3. About Me • Pavel Mička • Software architect at ZOOM International • Modernizing CallRecording and WorkForce Optimization application • Previously: Software engineer at Cisco Systems • Breaking up monolith, I helped to build • pavel.micka@zoomint.com • @pavelmicka_xyz
  • 5. Monolith - advantages • Default architectural style • Whole application in one piece • One deployable artifact • Easy to distribute • All data in one place • Doing cross-selects is trivial • Strong consistency model • Extremely good processing latency • There is no network…
  • 6. Monolith - drawbacks • Increasingly hard to maintain/evolve • Internal parts tightly coupled (interdependencies) • Technological monoculture • Hard to start/setup • A lot of dependencies • Hard to scale independently • Hard to assign clear responsibilities • Usually ends up in Big Ball of Mud • HA is often problematic (shared state) “If you have only a hammer, everything looks as a nail”
  • 8. Microservice architecture • Separately deployable • Built around bounded context • Vertical slice of functionality • Size: 2 pizza team • Internals are opaque • Services separated using API
  • 9. Microservices – advantages • Fast release cycle • Each service may be written using different technology • Are small • Extremely resilient, if written properly • Microservice architecture scales well • You can scale the technology by feature • More important: you can scale the TEAM
  • 10. Drawbacks: There is no silver bullet • Do not do microservices, if you have • Just started with the project • Legacy product without fast development • Limited automation • Slow release cycle & Waterfall • Small number of developers • Low latency requirements • Low memory requirements
  • 12. The “showcase” service • Audit log • Used for compliance reasons • Logs all user actions • All user actions must be logged • This is real production code • Basic tech facts • Java 8/11 • Spring Boot • Built using Gradle • Artifact: RPM
  • 16. Implement DevOps • Take care of the full lifecycle • Create GIT repo • Create build pipeline • Build the code • Test it • Get it to distribution • Distribute it • Maintain it • Microservices are about agility & rapid delivery • If you need an external team for everything, you will not be very agile…
  • 17. Describe you data model • What are the entities in your business? • Formalize them • What properties/relations do they have? • How they fulfil the business use case? • How do you want to expand your model from business perspective? • Regardless if you are 10 years on the market, perform this exercise… • You may find out that you current model contains contradictions • And/Or does not fully satisfy the needs of your customers
  • 19. Standardize quality & testing • Use latest versions of libraries • OWASP/Continuous security is a good vehicle • Other teams are easily able to help, when scenarios are covered by tests • Tests are easily executable without exotic setup • Consider: TestContainers • Do not: run tests against “database in lab”
  • 20. Standardize Versioning • Use semantic versioning (1.3.2) • Only visible API is versioned • Patch == No change in API (bugfixes, new libs…) • Minor == Additive change in API • Major == Something was removed/modified • Pitfalls • Change in interpretation is breaking (timestamp in ms vs. ns) • If you rewrite JS to Cobol, but keep API, its just a patch change
  • 22. Create a paved path • Using Spring Boot is just the start • Create opinionated chassis
  • 23. Build in resiliency • Because of network you cannot distinguish: • Request was lost on the way • Request failed during processing • Response failed • Request or response are still on their way • Request/response can though a different network line • Slow request causes cascading failures • Use bulkheads • Use circuit breakers
  • 26. Build is also a code • Build is also a code • Gradle & Maven: use plugins • Continuous integration: use templates Example • apply plugin: ‘quality-plugin’ • Coverage, PMD, Checkstyle, licenses, reports, OWASP • Build of RPM or Docker should be also a one-liner • Preconditon: all projects have the same structure
  • 27. Use integration tests • Integration tests == testing the component as a whole, DB included • Unit Tests: You have unit tested app & its security in isolation • Performing integration tests suite should be relatively cheap • The service surface is small • Gives you sense of security that its really works • You still need a unit test suite
  • 28. Avoid N+1 scenarios • 2 services (one handling users, other logs) • Load N users, load logs for each one separately • May somehow work in a single transaction • BUT if logs and users are in different microservice, it will not work • You will tend to implement caches (hint: don’t) • Implement multiget
  • 29. Observability: Monitoring and Logging • Centralized monitoring • Have an overview of all state of all services in one place • Use TVs in your office for dashboards (if you are a cloud company) • Centralized logging • Have log messages in one place (you want to correlate) • Its not fun to search the flow through 7 services, each with 3 instances • Distributed tracing • Be able to track your request across many services
  • 30.
  • 31.
  • 32. What about consistency? • With microservices you get eventual consistency • Eventually the system will end up in consistent state • Heavy use of queues • Idempotent operations • Strong consistency via distributed transactions? • Creates more issues than is really solves • Its expensive • Some error states need to be manually resolved in 2 phase commit
  • 33. Eventually consistent delete • Delete agent and all his logs • Message cannot be lost • If delete from customer db fails • The message was not ACKed • The same applies to billing • This is choreography based • Other option: orchestration