SlideShare uma empresa Scribd logo
1 de 23
Keep Your Contracts in Check:
Design and Evolution of APIs in
Microservice Architecture
About Me
• .NET Developer at Lohika
• 5+ years of commercial
experience
• 3+ years at Lohika
• Participated in development of 4
microservice-based systems,
from 3 to 20+ services each.
• Ways of interservice communication and how not to get lost with
your options.
• API First development and how it can save time in multi-team
environment.
• SwaggerHub as a single Point of truth for REST API
• Best practices for gRPC contracts and how to deal with changes in
them.
• Kafka Schema Registry - contract coordinator for different
messaging scenarios
Agenda
Tourist Agency Application
Happy Monolith Past
SQL
TripPlanningService
CustomerService HotelBookingService
CarRentalService
Bright Microservice Future
SQL
TripPlanningService
CustomerService HotelBookingService
CarRentalService
SQL
Mongo
DB
????
Synchronicity
• Synchronous protocol
• Asynchronous protocol
Number of
receivers
• Single receiver
• Multiple receivers
Communication types
Synchronous protocol ≠ Synchronous Communication
Client
Trip Planning
Service
Car Booking
Service
Customer
Service
HTTP Sync
Request
HTTP Sync
Response
HTTP Sync
Request
HTTP Sync
Response
HTTP Sync
Request
HTTP Sync
Response
Client
Trip Planning
Service
Car Booking
Service
Customer
Service
HTTP Sync
Request
HTTP
Polling
HTTP
Polling
HTTP Sync
Response
HTTP
Polling
HTTP Sync
Request
HTTP Sync
Response
Number of Receivers
Single Receiver - Command
• At Least Once delivery
• Exactly Once processing
• Order of execution is important
• Producer expects to receive
response
Multiple Receivers - Event
• Fire and Forget
• Louse Coupling between
producers and consumers
Trip Planning
Service
Car Booking
Service
Book a car for
specific dates
Customer
Service
Car Booking
Service
Trip Planning
Service
Hotel Booking
Service
Customer Info
Changed
Who Owns the Contract?
Single Receiver - Command
• The inbound queue identifier
• The format of the processed
command types
Multiple Receivers - Event
• The topic identifier
• The format of all emitted
events
Command Model
Consumer Producer
Business Logic Implements business Logic Triggers business logic
Quantity Always one Often many
Autonomy Can run on its own Fails if no consumer
Consumer owns the contract
Event Model
Consumer Producer
Business Logic Implements business Logic Reports an event
Quantity Usually many Only one
Autonomy Subordinate to producer Can run on its own
Producer owns the contract
Development Approaches
Code First
Contract First
Code First
Team Gonzo - Customer Service
Team Kermit – Car Rental Service
Investigate Implement Test
Investigate Implement Test
Contract First
Team Gonzo - Customer Service
Team Kermit – Car Rental Service
Define API
Contract
Investigate Implement
Investigate Implement Test
Test
Agree on API
Contract
• Development teams does not block each other
• Good and consistent communication between teams
• Consistent API models
• Separation of concerns
• Reusability
• Easy documentation
Contract First
REST Contracts - OpenAPI
API description format for REST APIs. An OpenAPI file allows you to
describe your entire API, including:
• Available endpoints (/users) and operations on each endpoint (GET
/users, POST /users)
• Operation parameters Input and output for each operation
• Authentication methods
• Contact information, license, terms of use and other information.
Demo Time
gRPC Contracts – Protocol Buffers
ProtoBuf
Definitions
protoc
Compiler
.NET
Go
Kotlin
gRPC Server
gRPC Client
2. Compile
1. Define 3. Implement
Keeping ProtoBuf in Line
Pick Style Guide
• Google’s Style Guide
• Uber’s Style Guide (V1/V2)
Lint your ProtoBuf files & Check for Breaking Changes
• Prototool
• Buf
Setup Mock Servers
• GripMock
Messaging Contracts – Kafka Schema Registry
Compatibility Types
Compatibility Type Changes Allowed Upgrade First
BACKWARD - Delete Fields
- Add optional fields
Consumers
FORWARD - Add fields
- Delete optional fields
Producers
FULL - Add optional fields
- Delete optional fields
Any order
NONE - Any changes Usually - custom migration logic
Useful Tools
• Stoplight Studio - https://stoplight.io/studio/
• Spectral - https://stoplight.io/open-source/spectral/
• OpenAPI-diff -https://github.com/OpenAPITools/openapi-diff
OpenAPI Tooling
• SwaggerHub - https://swagger.io/tools/swaggerhub/
• SwaggerHub CLI - https://github.com/SmartBear/swaggerhub-cli
SwaggerHub
• Prototool - https://github.com/uber/prototool
• GripMock - https://github.com/tokopedia/gripmock
gRPC Tooling
Thank You!

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

apidays LIVE Singapore - Next-generation microservice architecture based on A...
apidays LIVE Singapore - Next-generation microservice architecture based on A...apidays LIVE Singapore - Next-generation microservice architecture based on A...
apidays LIVE Singapore - Next-generation microservice architecture based on A...
 
The Effect of Microservices on API Design
The Effect of Microservices on API DesignThe Effect of Microservices on API Design
The Effect of Microservices on API Design
 
apidays LIVE London 2021 - API design is where culture and tech meet each oth...
apidays LIVE London 2021 - API design is where culture and tech meet each oth...apidays LIVE London 2021 - API design is where culture and tech meet each oth...
apidays LIVE London 2021 - API design is where culture and tech meet each oth...
 
Api clarity webinar
Api clarity webinarApi clarity webinar
Api clarity webinar
 
apidays LIVE Paris 2021 - Building an Accessible API Spec with Traditional En...
apidays LIVE Paris 2021 - Building an Accessible API Spec with Traditional En...apidays LIVE Paris 2021 - Building an Accessible API Spec with Traditional En...
apidays LIVE Paris 2021 - Building an Accessible API Spec with Traditional En...
 
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
 
apidays LIVE Australia 2021 - From apps to APIs: how no-code is transforming ...
apidays LIVE Australia 2021 - From apps to APIs: how no-code is transforming ...apidays LIVE Australia 2021 - From apps to APIs: how no-code is transforming ...
apidays LIVE Australia 2021 - From apps to APIs: how no-code is transforming ...
 
apidays LIVE Paris 2021 - Why Can’t Us Consumers Have APIs by Salman Farmanfa...
apidays LIVE Paris 2021 - Why Can’t Us Consumers Have APIs by Salman Farmanfa...apidays LIVE Paris 2021 - Why Can’t Us Consumers Have APIs by Salman Farmanfa...
apidays LIVE Paris 2021 - Why Can’t Us Consumers Have APIs by Salman Farmanfa...
 
apidays LIVE JAKARTA - Productising APIs: A journey in how we built API produ...
apidays LIVE JAKARTA - Productising APIs: A journey in how we built API produ...apidays LIVE JAKARTA - Productising APIs: A journey in how we built API produ...
apidays LIVE JAKARTA - Productising APIs: A journey in how we built API produ...
 
apidays LIVE Paris 2021 - API design is where culture and tech meet each othe...
apidays LIVE Paris 2021 - API design is where culture and tech meet each othe...apidays LIVE Paris 2021 - API design is where culture and tech meet each othe...
apidays LIVE Paris 2021 - API design is where culture and tech meet each othe...
 
apidays LIVE Hong Kong - Open Banking, Yin and Yang in Hong Kong by Simon Red...
apidays LIVE Hong Kong - Open Banking, Yin and Yang in Hong Kong by Simon Red...apidays LIVE Hong Kong - Open Banking, Yin and Yang in Hong Kong by Simon Red...
apidays LIVE Hong Kong - Open Banking, Yin and Yang in Hong Kong by Simon Red...
 
apidays LIVE London 2021 - Federating the Content Layer by Jamie Barton, Grap...
apidays LIVE London 2021 - Federating the Content Layer by Jamie Barton, Grap...apidays LIVE London 2021 - Federating the Content Layer by Jamie Barton, Grap...
apidays LIVE London 2021 - Federating the Content Layer by Jamie Barton, Grap...
 
Tools and techniques for APIs
Tools and techniques for APIsTools and techniques for APIs
Tools and techniques for APIs
 
apidays LIVE Australia 2021 - Confessions of a Product Geek : My First API BY...
apidays LIVE Australia 2021 - Confessions of a Product Geek : My First API BY...apidays LIVE Australia 2021 - Confessions of a Product Geek : My First API BY...
apidays LIVE Australia 2021 - Confessions of a Product Geek : My First API BY...
 
apidays LIVE Australia 2021 - Designing APIs: Just Enough is Perfect! by Dami...
apidays LIVE Australia 2021 - Designing APIs: Just Enough is Perfect! by Dami...apidays LIVE Australia 2021 - Designing APIs: Just Enough is Perfect! by Dami...
apidays LIVE Australia 2021 - Designing APIs: Just Enough is Perfect! by Dami...
 
apidays LIVE Paris 2021 - Building an analytics API by David Wobrock, Botify
apidays LIVE Paris 2021 - Building an analytics API by David Wobrock, Botifyapidays LIVE Paris 2021 - Building an analytics API by David Wobrock, Botify
apidays LIVE Paris 2021 - Building an analytics API by David Wobrock, Botify
 
apidays LIVE Paris 2021 - Getting started with Event-Driven APis by Hugo Guer...
apidays LIVE Paris 2021 - Getting started with Event-Driven APis by Hugo Guer...apidays LIVE Paris 2021 - Getting started with Event-Driven APis by Hugo Guer...
apidays LIVE Paris 2021 - Getting started with Event-Driven APis by Hugo Guer...
 
Blood, sweat, and creating an API handbook
Blood, sweat, and creating an API handbookBlood, sweat, and creating an API handbook
Blood, sweat, and creating an API handbook
 
apidays LIVE Australia 2021 - Designing Embedded Platforms by Jeremy Glassenb...
apidays LIVE Australia 2021 - Designing Embedded Platforms by Jeremy Glassenb...apidays LIVE Australia 2021 - Designing Embedded Platforms by Jeremy Glassenb...
apidays LIVE Australia 2021 - Designing Embedded Platforms by Jeremy Glassenb...
 
apidays LIVE London 2021 - Advanced Authentication patterns at the Edge by De...
apidays LIVE London 2021 - Advanced Authentication patterns at the Edge by De...apidays LIVE London 2021 - Advanced Authentication patterns at the Edge by De...
apidays LIVE London 2021 - Advanced Authentication patterns at the Edge by De...
 

Semelhante a Design and Evolution of APIs in Microservice Architecture

Building high performance microservices in finance with Apache Thrift
Building high performance microservices in finance with Apache ThriftBuilding high performance microservices in finance with Apache Thrift
Building high performance microservices in finance with Apache Thrift
RX-M Enterprises LLC
 
API Gateways are going through an identity crisis
API Gateways are going through an identity crisisAPI Gateways are going through an identity crisis
API Gateways are going through an identity crisis
Christian Posta
 

Semelhante a Design and Evolution of APIs in Microservice Architecture (20)

A Snapshot of API Design Trends In 2019
A Snapshot of API Design Trends In 2019A Snapshot of API Design Trends In 2019
A Snapshot of API Design Trends In 2019
 
Building high performance microservices in finance with Apache Thrift
Building high performance microservices in finance with Apache ThriftBuilding high performance microservices in finance with Apache Thrift
Building high performance microservices in finance with Apache Thrift
 
API Gateways are going through an identity crisis
API Gateways are going through an identity crisisAPI Gateways are going through an identity crisis
API Gateways are going through an identity crisis
 
Austin API Summit 2018: Are REST APIs Still Relevant Today?
Austin API Summit 2018: Are REST APIs Still Relevant Today?Austin API Summit 2018: Are REST APIs Still Relevant Today?
Austin API Summit 2018: Are REST APIs Still Relevant Today?
 
Are REST APIs Still Relevant Today?
Are REST APIs Still Relevant Today?Are REST APIs Still Relevant Today?
Are REST APIs Still Relevant Today?
 
Cloud Native API Design and Management
Cloud Native API Design and ManagementCloud Native API Design and Management
Cloud Native API Design and Management
 
Kong API Gateway.pdf
Kong API Gateway.pdfKong API Gateway.pdf
Kong API Gateway.pdf
 
Yotpo microservices
Yotpo microservicesYotpo microservices
Yotpo microservices
 
Kong Workshop.pdf
Kong Workshop.pdfKong Workshop.pdf
Kong Workshop.pdf
 
Five Ways to Scale your API Without Touching Your Code
Five Ways to Scale your API Without Touching Your CodeFive Ways to Scale your API Without Touching Your Code
Five Ways to Scale your API Without Touching Your Code
 
Building Language Agnostic APIs with gRPC - JavaDay Istanbul 2017
Building Language Agnostic APIs with gRPC - JavaDay Istanbul 2017Building Language Agnostic APIs with gRPC - JavaDay Istanbul 2017
Building Language Agnostic APIs with gRPC - JavaDay Istanbul 2017
 
SignalR or gRPC: Choosing the Right Technology for Real-Time Communication in...
SignalR or gRPC: Choosing the Right Technology for Real-Time Communication in...SignalR or gRPC: Choosing the Right Technology for Real-Time Communication in...
SignalR or gRPC: Choosing the Right Technology for Real-Time Communication in...
 
Asynchronous API Testing: Trends, Tools & More | Calidad Infotech
Asynchronous API Testing: Trends, Tools & More | Calidad Infotech Asynchronous API Testing: Trends, Tools & More | Calidad Infotech
Asynchronous API Testing: Trends, Tools & More | Calidad Infotech
 
Go mico
Go micoGo mico
Go mico
 
apidays Australia 2022 - Schemas are not contracts!, Matt Fellows, Pactflow
apidays Australia 2022 - Schemas are not contracts!, Matt Fellows, Pactflowapidays Australia 2022 - Schemas are not contracts!, Matt Fellows, Pactflow
apidays Australia 2022 - Schemas are not contracts!, Matt Fellows, Pactflow
 
Colt inter-provider SDN NNIs and APIs
Colt inter-provider SDN NNIs and APIsColt inter-provider SDN NNIs and APIs
Colt inter-provider SDN NNIs and APIs
 
Moran wsmx
Moran wsmxMoran wsmx
Moran wsmx
 
RefCard API Architecture Strategy
RefCard API Architecture StrategyRefCard API Architecture Strategy
RefCard API Architecture Strategy
 
Node.js BFFs - our way to the better/micro frontends
Node.js BFFs - our way to the better/micro frontendsNode.js BFFs - our way to the better/micro frontends
Node.js BFFs - our way to the better/micro frontends
 
[WSO2 Integration Summit Nairobi 2019] Role of Integration in an API Driven W...
[WSO2 Integration Summit Nairobi 2019] Role of Integration in an API Driven W...[WSO2 Integration Summit Nairobi 2019] Role of Integration in an API Driven W...
[WSO2 Integration Summit Nairobi 2019] Role of Integration in an API Driven W...
 

Mais de Lohika_Odessa_TechTalks

Micro-frontends – is it a new normal?
Micro-frontends – is it a new normal?Micro-frontends – is it a new normal?
Micro-frontends – is it a new normal?
Lohika_Odessa_TechTalks
 
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalksSelenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
Lohika_Odessa_TechTalks
 

Mais de Lohika_Odessa_TechTalks (20)

OAuth2 Authorization Server Under the Hood
OAuth2 Authorization Server Under the HoodOAuth2 Authorization Server Under the Hood
OAuth2 Authorization Server Under the Hood
 
Debugging Microservices - key challenges and techniques - Microservices Odesa...
Debugging Microservices - key challenges and techniques - Microservices Odesa...Debugging Microservices - key challenges and techniques - Microservices Odesa...
Debugging Microservices - key challenges and techniques - Microservices Odesa...
 
Micro-frontends – is it a new normal?
Micro-frontends – is it a new normal?Micro-frontends – is it a new normal?
Micro-frontends – is it a new normal?
 
Multithreading in go
Multithreading in goMultithreading in go
Multithreading in go
 
Druid - Interactive Analytics At Scale
Druid - Interactive Analytics At ScaleDruid - Interactive Analytics At Scale
Druid - Interactive Analytics At Scale
 
DevOps Odessa #TechTalks 21.01.2020
DevOps Odessa #TechTalks 21.01.2020DevOps Odessa #TechTalks 21.01.2020
DevOps Odessa #TechTalks 21.01.2020
 
Jenkins' shared libraries in action
Jenkins' shared libraries in actionJenkins' shared libraries in action
Jenkins' shared libraries in action
 
Prometheus: infrastructure and application monitoring in kubernetes cluster
Prometheus: infrastructure and application monitoring in kubernetes clusterPrometheus: infrastructure and application monitoring in kubernetes cluster
Prometheus: infrastructure and application monitoring in kubernetes cluster
 
Architectural peripherals of react by Vadym Zhiltsov
Architectural peripherals of react by Vadym ZhiltsovArchitectural peripherals of react by Vadym Zhiltsov
Architectural peripherals of react by Vadym Zhiltsov
 
React native by example by Vadim Ruban
React native by example by Vadim RubanReact native by example by Vadim Ruban
React native by example by Vadim Ruban
 
Aws lambda by Leonid Amigud
Aws lambda by Leonid AmigudAws lambda by Leonid Amigud
Aws lambda by Leonid Amigud
 
Congratulations, you have been promoted to a manager role. You`ve got new pro...
Congratulations, you have been promoted to a manager role. You`ve got new pro...Congratulations, you have been promoted to a manager role. You`ve got new pro...
Congratulations, you have been promoted to a manager role. You`ve got new pro...
 
"Don't touch me and give me my money" or how motivate people who can but don...
"Don't touch me and give me my money" or  how motivate people who can but don..."Don't touch me and give me my money" or  how motivate people who can but don...
"Don't touch me and give me my money" or how motivate people who can but don...
 
Docker based Architecture by Denys Serdiuk
Docker based Architecture by Denys SerdiukDocker based Architecture by Denys Serdiuk
Docker based Architecture by Denys Serdiuk
 
SparkSpark in the Big Data dark by Sergey Levandovskiy
SparkSpark in the Big Data dark by Sergey Levandovskiy  SparkSpark in the Big Data dark by Sergey Levandovskiy
SparkSpark in the Big Data dark by Sergey Levandovskiy
 
Burnout and how to avoid it in your team. Responsible person's issue by Andre...
Burnout and how to avoid it in your team. Responsible person's issue by Andre...Burnout and how to avoid it in your team. Responsible person's issue by Andre...
Burnout and how to avoid it in your team. Responsible person's issue by Andre...
 
Performance evaluation process as a way to empower your employees and help th...
Performance evaluation process as a way to empower your employees and help th...Performance evaluation process as a way to empower your employees and help th...
Performance evaluation process as a way to empower your employees and help th...
 
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalksSelenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
Selenium with py test by Alexandr Vasyliev for Lohika Odessa Python TechTalks
 
" Performance testing for Automation QA - why and how " by Andrey Kovalenko f...
" Performance testing for Automation QA - why and how " by Andrey Kovalenko f..." Performance testing for Automation QA - why and how " by Andrey Kovalenko f...
" Performance testing for Automation QA - why and how " by Andrey Kovalenko f...
 
"WEB applications security testing" by Kirill Semenov for Lohika Odessa QA Te...
"WEB applications security testing" by Kirill Semenov for Lohika Odessa QA Te..."WEB applications security testing" by Kirill Semenov for Lohika Odessa QA Te...
"WEB applications security testing" by Kirill Semenov for Lohika Odessa QA Te...
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Design and Evolution of APIs in Microservice Architecture

  • 1. Keep Your Contracts in Check: Design and Evolution of APIs in Microservice Architecture
  • 2. About Me • .NET Developer at Lohika • 5+ years of commercial experience • 3+ years at Lohika • Participated in development of 4 microservice-based systems, from 3 to 20+ services each.
  • 3. • Ways of interservice communication and how not to get lost with your options. • API First development and how it can save time in multi-team environment. • SwaggerHub as a single Point of truth for REST API • Best practices for gRPC contracts and how to deal with changes in them. • Kafka Schema Registry - contract coordinator for different messaging scenarios Agenda
  • 4. Tourist Agency Application Happy Monolith Past SQL TripPlanningService CustomerService HotelBookingService CarRentalService
  • 5. Bright Microservice Future SQL TripPlanningService CustomerService HotelBookingService CarRentalService SQL Mongo DB ????
  • 6. Synchronicity • Synchronous protocol • Asynchronous protocol Number of receivers • Single receiver • Multiple receivers Communication types
  • 7. Synchronous protocol ≠ Synchronous Communication Client Trip Planning Service Car Booking Service Customer Service HTTP Sync Request HTTP Sync Response HTTP Sync Request HTTP Sync Response HTTP Sync Request HTTP Sync Response Client Trip Planning Service Car Booking Service Customer Service HTTP Sync Request HTTP Polling HTTP Polling HTTP Sync Response HTTP Polling HTTP Sync Request HTTP Sync Response
  • 8. Number of Receivers Single Receiver - Command • At Least Once delivery • Exactly Once processing • Order of execution is important • Producer expects to receive response Multiple Receivers - Event • Fire and Forget • Louse Coupling between producers and consumers Trip Planning Service Car Booking Service Book a car for specific dates Customer Service Car Booking Service Trip Planning Service Hotel Booking Service Customer Info Changed
  • 9. Who Owns the Contract? Single Receiver - Command • The inbound queue identifier • The format of the processed command types Multiple Receivers - Event • The topic identifier • The format of all emitted events
  • 10. Command Model Consumer Producer Business Logic Implements business Logic Triggers business logic Quantity Always one Often many Autonomy Can run on its own Fails if no consumer Consumer owns the contract
  • 11. Event Model Consumer Producer Business Logic Implements business Logic Reports an event Quantity Usually many Only one Autonomy Subordinate to producer Can run on its own Producer owns the contract
  • 13. Code First Team Gonzo - Customer Service Team Kermit – Car Rental Service Investigate Implement Test Investigate Implement Test
  • 14. Contract First Team Gonzo - Customer Service Team Kermit – Car Rental Service Define API Contract Investigate Implement Investigate Implement Test Test Agree on API Contract
  • 15. • Development teams does not block each other • Good and consistent communication between teams • Consistent API models • Separation of concerns • Reusability • Easy documentation Contract First
  • 16. REST Contracts - OpenAPI API description format for REST APIs. An OpenAPI file allows you to describe your entire API, including: • Available endpoints (/users) and operations on each endpoint (GET /users, POST /users) • Operation parameters Input and output for each operation • Authentication methods • Contact information, license, terms of use and other information.
  • 18. gRPC Contracts – Protocol Buffers ProtoBuf Definitions protoc Compiler .NET Go Kotlin gRPC Server gRPC Client 2. Compile 1. Define 3. Implement
  • 19. Keeping ProtoBuf in Line Pick Style Guide • Google’s Style Guide • Uber’s Style Guide (V1/V2) Lint your ProtoBuf files & Check for Breaking Changes • Prototool • Buf Setup Mock Servers • GripMock
  • 20. Messaging Contracts – Kafka Schema Registry
  • 21. Compatibility Types Compatibility Type Changes Allowed Upgrade First BACKWARD - Delete Fields - Add optional fields Consumers FORWARD - Add fields - Delete optional fields Producers FULL - Add optional fields - Delete optional fields Any order NONE - Any changes Usually - custom migration logic
  • 22. Useful Tools • Stoplight Studio - https://stoplight.io/studio/ • Spectral - https://stoplight.io/open-source/spectral/ • OpenAPI-diff -https://github.com/OpenAPITools/openapi-diff OpenAPI Tooling • SwaggerHub - https://swagger.io/tools/swaggerhub/ • SwaggerHub CLI - https://github.com/SmartBear/swaggerhub-cli SwaggerHub • Prototool - https://github.com/uber/prototool • GripMock - https://github.com/tokopedia/gripmock gRPC Tooling