SlideShare a Scribd company logo
Microservices: The Best Practices
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
Microservices: The Best Practices
Microservices: The Best Practices
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

More Related Content

PDF
Kafka Summit SF 2017 - Running Kafka for Maximum Pain
PPTX
Micro Services Architecture
PDF
J-Spring 2017 - Microservices in action at the Dutch National Police
PPTX
A Deeper Look Into Reactive Streams with Akka Streams 1.0 and Slick 3.0
PDF
Continuous Delivery Amsterdam - Microservices in action at the Dutch National...
PPTX
Building an OpenMRS Distribution - Lessons from KenyaEMR
PDF
Will ServerLess kill containers and Operations
PPTX
Advantages of Rails Framework
Kafka Summit SF 2017 - Running Kafka for Maximum Pain
Micro Services Architecture
J-Spring 2017 - Microservices in action at the Dutch National Police
A Deeper Look Into Reactive Streams with Akka Streams 1.0 and Slick 3.0
Continuous Delivery Amsterdam - Microservices in action at the Dutch National...
Building an OpenMRS Distribution - Lessons from KenyaEMR
Will ServerLess kill containers and Operations
Advantages of Rails Framework

What's hot (20)

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

Similar to Microservices: The Best Practices (20)

PPTX
Microservices: Yes or not?
PPTX
Introduction to Microservices
PPTX
Reactive Micro Services with Java seminar
PDF
Architectural Decisions: Smoothly and Consistently
PDF
Architectural Decisions: Smoothly and Consistently
KEY
Make It Cooler: Using Decentralized Version Control
PDF
QCon 2015 - Microservices Track Notes
PPTX
PDF
Microservice Architecture
PPTX
Microservice intro
PPTX
DevOps Days Ohio
PPTX
The Rocky Cloud Road
PDF
Microservices Architecture
PPTX
All about that reactive ui
PDF
Itsummit2015 blizzard
PDF
Software Architecture and Architectors: useless VS valuable
PDF
Devoxx PL 2018 - Microservices in action at the Dutch National Police
PPTX
Iot cloud service v2.0
PPTX
Why retail companies can't afford database downtime
PDF
How to grow your own Microservice?
Microservices: Yes or not?
Introduction to Microservices
Reactive Micro Services with Java seminar
Architectural Decisions: Smoothly and Consistently
Architectural Decisions: Smoothly and Consistently
Make It Cooler: Using Decentralized Version Control
QCon 2015 - Microservices Track Notes
Microservice Architecture
Microservice intro
DevOps Days Ohio
The Rocky Cloud Road
Microservices Architecture
All about that reactive ui
Itsummit2015 blizzard
Software Architecture and Architectors: useless VS valuable
Devoxx PL 2018 - Microservices in action at the Dutch National Police
Iot cloud service v2.0
Why retail companies can't afford database downtime
How to grow your own Microservice?
Ad

Recently uploaded (20)

PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Nekopoi APK 2025 free lastest update
PDF
Digital Strategies for Manufacturing Companies
PDF
top salesforce developer skills in 2025.pdf
PDF
System and Network Administration Chapter 2
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
L1 - Introduction to python Backend.pptx
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
Odoo POS Development Services by CandidRoot Solutions
PPTX
Introduction to Artificial Intelligence
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPT
Introduction Database Management System for Course Database
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PTS Company Brochure 2025 (1).pdf.......
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Nekopoi APK 2025 free lastest update
Digital Strategies for Manufacturing Companies
top salesforce developer skills in 2025.pdf
System and Network Administration Chapter 2
How to Migrate SBCGlobal Email to Yahoo Easily
CHAPTER 2 - PM Management and IT Context
L1 - Introduction to python Backend.pptx
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Odoo POS Development Services by CandidRoot Solutions
Introduction to Artificial Intelligence
Wondershare Filmora 15 Crack With Activation Key [2025
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
How to Choose the Right IT Partner for Your Business in Malaysia
Introduction Database Management System for Course Database
Operating system designcfffgfgggggggvggggggggg
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...

Microservices: The Best Practices

  • 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
  • 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