SlideShare una empresa de Scribd logo
1 de 33
Descargar para leer sin conexión
Designing Microservices with
NATS
October 8, 2021
Microservices
The term microservices architecture refers
to a distributed computing architecture that is
built using a set of small, autonomous
services that act as a cohesive unit to solve a
business problem or problems
Advantages of Microservices
● Build highly scalable applications
● Build robust applications that withstand failures
● Better utilization of computing infrastructure
● Helps innovation with reduced time to market
● Build modular systems that are easy to manage and maintain
Characteristics of Microservices
● Independently deployable
● Design for failure
● Decentralized data management
● Domain driven design (finite scope per service)
● Agile development
● Container based deployments
Challenges of Microservices
● Inter-service communication
● Observability
● Error handling and troubleshooting
● Security
Inter-service communication for microservices
● Service Mesh based approach
○ Point to point communication
○ Become complex with the increase of microservices
○ Separate data plane and control plane
● Message Broker based approach
○ Fully decoupled communication
○ Complexity does not increase with the number of microservices
○ Subject based messaging
NATS
NATS:
Modern messaging framework that
allows developers and operators to
build distributed systems
Why NATS?
● High performance:
○ NATS performs better than most of the existing message broker products, including
Kafka and RabbitMQ.
● Lightweight:
○ It does not need sophisticated hardware and complex deployment models to support
large message volumes.
● Simple to use:
○ It supplies a simple API to use the system. NATS has clients for over 30 programming
languages.
● At most once and at least once delivery:
○ Supports message guarantees required by applications.
● Support for event handling:
○ It can handle event streams with better performance.
NATS use cases
● Microservice-based applications:
○ Service mesh and inter-service messaging
● Event streaming applications:
○ Observability/analytics
○ Machine learning
○ Artificial intelligence
● Command and control-based systems:
○ Internet of Things (IoT) and edge computing
○ Telemetry/sensor data/command and control
● Augmenting or replacing legacy messaging systems
How NATS work?
● NATS uses a subject based messaging model with a fully decoupled publisher and a
subscriber
● Supports following message distribution mechanisms
○ Publish-Subscribe (topic based)
○ Request-Reply
○ Queue groups (load balancing)
● Messages are published on a subject and the consumers subscribe to the subject
● Wildcard subscriptions are allowed so that consumers can listen to messages from different
subjects and different publishers
NATS subject based messaging
● Supports wiretap messaging with
wildcard “>”
● Multi character wildcard can be
used to listen on a certain pattern of
subjects
● Specific subject name is used to
receive messages from specific
publishers
NATS request-reply messaging
● Publisher specifies a reply subject
(inbox)
● Subscriber respond through the
reply subject
● NATS can filter multiple responses
and send the first (fastest) response
NATS queue-groups messaging
● Publisher publishes on a subject. It
is not aware of the queue group
● Subscribers form a queue group by
specifying a common name for the
queue parameter
● Messages are delivered to the
subscribers in a load balanced
manner
NATS Clustering
● Helps scaling the NATS infrastructure according to the requirements of the application
● Clustering forms a fully connected server mesh. All nodes are aware of all the other nodes.
● Nodes are connected via sending simple messages (gossip) and does not require
pre-configuration of all the nodes
● Messages are replicated to one of the adjacent node so that node failure does not cause a
message loss
● Publisher and Subscriber can connect to different nodes (location transparency) to share
messages
● Most applications can be supported with a 3-node cluster
Microservices with NATS
Microservices Inner-Outer Architecture
● Microservices does not exist in isolation.
● Inner Architecture deals with
○ Individual microservices
○ Inter-Service Communication
● Outer Architecture deals with
○ Integration with other parts of the enterprise platform
○ Governance of the microservices teams and processes
○ Shared services such as automation, infrastructure, observability
Microservices Inner-Outer Architecture
Building an Outpatient Department (OPD) Application
● A hospital OPD unit performs various tasks related to patient care
● Patient Registration
○ Admit new patients to the unit and register them on the system
● Patient Inspection
○ A physician inspect the patient and decide on the next steps
● Patient Treatment
○ Based on the inspection, nurses take care of the temporary treatments including
medication and doing various tests
● Patient Release
○ Once the temporary treatment is done, patient is discharged from the unit and send
back home or admit to a long term ward for further treatments
OPD Application Design with NATS
OPD Application Implementation
● Each microservice has its own database to store data related to that microservice
● Messages are used to share data between services
● Registration Service stores the patient details in the database and publish an event to the
inspection service with the patient ID and token number
● Inspection Service listens to the event and do the inspection and update its database with
inspection details. The required information is passed to the treatment service via an event.
● Treatment service receives the event and take actions accordingly and store the medication
schedules and test results in its database. Once the patient is ready to be released, it sends a
message via an event to the release service.
● Release service receives the event and discharge the patient and update its database.
Securing Microservices
● Security for external communications
○ Client applications consuming the services
○ Different types of clients including mobile, web and
standalone
○ Require advanced, standard security
○ OAuth 2.0 is becoming the de facto
○ API Gateways provides a standard mechanism to
implement security
● Security for internal communications
○ Services communicate with the NATS server
○ NATS support basic authentication, key based
authentication, JWT based authentication
○ Security can be implemented with TLS only since
consumers are internal (trusted subsystem)
Observability for Microservices with NATS
● Observability is a characteristic of the platform which defines how well the internal states of
a platform can be inferred from the knowledge of its external output
● It is a responsibility of each component in the platform to implement enough observability
through the external output such as
○ Log entries
○ Health check endpoints
○ Metrics endpoints
○ Application dashboards
● NATS supports observability through
○ Logging
○ Monitoring endpoints
Implementing Observability for Microservices with NATS
Implementing Observability for Microservices with NATS
● Microservices implements /healthz and /metrics endpoints to provide application statistics
and status.
● Microservices publish logs to application specific log files
● NATS server has a separate log file and a set of endpoints to collect application statistics
● Prometheus collects application statistics from the endpoints of microservices and the NATS
server and publishes to Grafana
● Promtail and Loki collects log entries and publishes to Grafana for visualization
● Grafana is used to create dashboards for microservices and NATS server monitoring and
alert generation
Microservices and Integration Platforms
● Enterprise platforms consists of heterogeneous systems that needs to be integrated.
● Microservices based applications are one such component in the overall architecture.
● Integration Platforms plays a pivotal role in enterprise by doing
○ Application Integration
○ Data Integration
○ B2B Integration
○ API Management
● Microservices needs to co-exist with Integration Platforms
Microservices and Integration Platforms
Microservices and Integration Platforms
● API-driven architecture is common within enterprise software platforms
● Services implemented at different layers based on their functionality and exposes APIs so
that subsequent layers can consume
● Microservices can implement services at one of these layers or at core business functionality
layer
● Microservices can integrate with other parts of the enterprise platform through the
integration platform since it supports the interoperability and acts as the anti-corruption
layer
Future of Microservices and NATS
● Trends/Developments in Microservices domain
○ Service Mesh is becoming popular though most people still failing to use it
○ Usage of Saga pattern to implement transactional microservices
○ Serverless platforms provides easier approach to build microservices based applications
● What’s new in NATS?
○ JetStream is becoming popular for streaming use cases of NATS which requires
advanced message delivery guarantees and persistence
○ NATS is used to build asynchronous logging frameworks and Service Mesh
Future of Microservices and NATS
● Trends/Developments in Microservices domain
○ Service Mesh is becoming popular though most people still failing to use it
○ Usage of Saga pattern to implement transactional microservices
○ Serverless platforms provides easier approach to build microservices based applications
● What’s new in NATS?
○ JetStream is becoming popular for streaming use cases of NATS which requires
advanced message delivery guarantees and persistence
○ NATS is used to build asynchronous logging frameworks and Service Mesh
Learn More
● The book that contains more
details can be found here
https://www.packtpub.com/product/d
esigning-microservices-platforms-wit
h-nats/9781801072212
Follow me
Chanaka Fernando, Associate
Director @ WSO2
Medium - https://medium.com/@chanakaudaya
Twitter - https://twitter.com/chanakaudaya
LinkedIn - https://www.linkedin.com/in/chanakaudaya
Github - https://github.com/chanakaudaya

Más contenido relacionado

La actualidad más candente

Microservices, Apache Kafka, Node, Dapr and more - Part Two (Fontys Hogeschoo...
Microservices, Apache Kafka, Node, Dapr and more - Part Two (Fontys Hogeschoo...Microservices, Apache Kafka, Node, Dapr and more - Part Two (Fontys Hogeschoo...
Microservices, Apache Kafka, Node, Dapr and more - Part Two (Fontys Hogeschoo...
Lucas Jellema
 

La actualidad más candente (20)

The Zen of High Performance Messaging with NATS
The Zen of High Performance Messaging with NATS The Zen of High Performance Messaging with NATS
The Zen of High Performance Messaging with NATS
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetes
 
NATS vs HTTP for Interservice Communication
NATS vs HTTP for Interservice CommunicationNATS vs HTTP for Interservice Communication
NATS vs HTTP for Interservice Communication
 
Microservices, Apache Kafka, Node, Dapr and more - Part Two (Fontys Hogeschoo...
Microservices, Apache Kafka, Node, Dapr and more - Part Two (Fontys Hogeschoo...Microservices, Apache Kafka, Node, Dapr and more - Part Two (Fontys Hogeschoo...
Microservices, Apache Kafka, Node, Dapr and more - Part Two (Fontys Hogeschoo...
 
NATS for Modern Messaging and Microservices
NATS for Modern Messaging and MicroservicesNATS for Modern Messaging and Microservices
NATS for Modern Messaging and Microservices
 
Service mesh
Service meshService mesh
Service mesh
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
 
Actor Patterns and NATS - Boulder Meetup
Actor Patterns and NATS - Boulder MeetupActor Patterns and NATS - Boulder Meetup
Actor Patterns and NATS - Boulder Meetup
 
Deploy Secure and Scalable Services Across Kubernetes Clusters with NATS
Deploy Secure and Scalable Services Across Kubernetes Clusters with NATSDeploy Secure and Scalable Services Across Kubernetes Clusters with NATS
Deploy Secure and Scalable Services Across Kubernetes Clusters with NATS
 
Service discovery with Eureka and Spring Cloud
Service discovery with Eureka and Spring CloudService discovery with Eureka and Spring Cloud
Service discovery with Eureka and Spring Cloud
 
OpenStack Architecture
OpenStack ArchitectureOpenStack Architecture
OpenStack Architecture
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
 
SingleStore & Kafka: Better Together to Power Modern Real-Time Data Architect...
SingleStore & Kafka: Better Together to Power Modern Real-Time Data Architect...SingleStore & Kafka: Better Together to Power Modern Real-Time Data Architect...
SingleStore & Kafka: Better Together to Power Modern Real-Time Data Architect...
 
Microservices Architecture & Testing Strategies
Microservices Architecture & Testing StrategiesMicroservices Architecture & Testing Strategies
Microservices Architecture & Testing Strategies
 
Kafka Tutorial - Introduction to Apache Kafka (Part 1)
Kafka Tutorial - Introduction to Apache Kafka (Part 1)Kafka Tutorial - Introduction to Apache Kafka (Part 1)
Kafka Tutorial - Introduction to Apache Kafka (Part 1)
 
Introduction to microservices
Introduction to microservicesIntroduction to microservices
Introduction to microservices
 
Azure kubernetes service (aks)
Azure kubernetes service (aks)Azure kubernetes service (aks)
Azure kubernetes service (aks)
 
Apache Kafka vs RabbitMQ: Fit For Purpose / Decision Tree
Apache Kafka vs RabbitMQ: Fit For Purpose / Decision TreeApache Kafka vs RabbitMQ: Fit For Purpose / Decision Tree
Apache Kafka vs RabbitMQ: Fit For Purpose / Decision Tree
 
How Uber scaled its Real Time Infrastructure to Trillion events per day
How Uber scaled its Real Time Infrastructure to Trillion events per dayHow Uber scaled its Real Time Infrastructure to Trillion events per day
How Uber scaled its Real Time Infrastructure to Trillion events per day
 
Event Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQEvent Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQ
 

Similar a Designing microservices platforms with nats

Similar a Designing microservices platforms with nats (20)

Ato Z of Microservices Architecture by Systango
Ato Z of Microservices Architecture by SystangoAto Z of Microservices Architecture by Systango
Ato Z of Microservices Architecture by Systango
 
NGINX Microservices Reference Architecture: What’s in Store for 2019 – EMEA
NGINX Microservices Reference Architecture: What’s in Store for 2019 – EMEANGINX Microservices Reference Architecture: What’s in Store for 2019 – EMEA
NGINX Microservices Reference Architecture: What’s in Store for 2019 – EMEA
 
Kenzan: Architecting for Microservices
Kenzan: Architecting for MicroservicesKenzan: Architecting for Microservices
Kenzan: Architecting for Microservices
 
1 (1).pptx
1 (1).pptx1 (1).pptx
1 (1).pptx
 
Introduction to Microservices Architecture - SECCOMP 2020
Introduction to Microservices Architecture - SECCOMP 2020Introduction to Microservices Architecture - SECCOMP 2020
Introduction to Microservices Architecture - SECCOMP 2020
 
Introduction to Microservices.pdf
Introduction to Microservices.pdfIntroduction to Microservices.pdf
Introduction to Microservices.pdf
 
Istio and Kubernetes Relationship
Istio and Kubernetes RelationshipIstio and Kubernetes Relationship
Istio and Kubernetes Relationship
 
Microservices-101
Microservices-101Microservices-101
Microservices-101
 
A New Way of Thinking | NATS 2.0 & Connectivity
A New Way of Thinking | NATS 2.0 & ConnectivityA New Way of Thinking | NATS 2.0 & Connectivity
A New Way of Thinking | NATS 2.0 & Connectivity
 
APIdays Paris 2019 - Cloud native API Management for Microservices on a Servi...
APIdays Paris 2019 - Cloud native API Management for Microservices on a Servi...APIdays Paris 2019 - Cloud native API Management for Microservices on a Servi...
APIdays Paris 2019 - Cloud native API Management for Microservices on a Servi...
 
Building microservices on azure
Building microservices on azureBuilding microservices on azure
Building microservices on azure
 
Docker microservices and the service mesh
Docker microservices and the service meshDocker microservices and the service mesh
Docker microservices and the service mesh
 
[APIdays Paris 2019] API Management in Service Mesh Using Istio and WSO2 API ...
[APIdays Paris 2019] API Management in Service Mesh Using Istio and WSO2 API ...[APIdays Paris 2019] API Management in Service Mesh Using Istio and WSO2 API ...
[APIdays Paris 2019] API Management in Service Mesh Using Istio and WSO2 API ...
 
MRA AMA: Ingenious: The Journey to Service Mesh using a Microservices Demo App
MRA AMA: Ingenious: The Journey to Service Mesh using a Microservices Demo AppMRA AMA: Ingenious: The Journey to Service Mesh using a Microservices Demo App
MRA AMA: Ingenious: The Journey to Service Mesh using a Microservices Demo App
 
Ledingkart Meetup #1: Monolithic to microservices in action
Ledingkart Meetup #1: Monolithic to microservices in actionLedingkart Meetup #1: Monolithic to microservices in action
Ledingkart Meetup #1: Monolithic to microservices in action
 
DevOps-training-in-chandigarh-Join-now--
DevOps-training-in-chandigarh-Join-now--DevOps-training-in-chandigarh-Join-now--
DevOps-training-in-chandigarh-Join-now--
 
Micro Services Intro
Micro Services IntroMicro Services Intro
Micro Services Intro
 
Service Mesh Talk for CTO Forum
Service Mesh Talk for CTO ForumService Mesh Talk for CTO Forum
Service Mesh Talk for CTO Forum
 
Cloud Computing and Data Centers
Cloud Computing and Data CentersCloud Computing and Data Centers
Cloud Computing and Data Centers
 
[WSO2Con Asia 2018] Talk Microservices to Me: The Role of IAM in Microservice...
[WSO2Con Asia 2018] Talk Microservices to Me: The Role of IAM in Microservice...[WSO2Con Asia 2018] Talk Microservices to Me: The Role of IAM in Microservice...
[WSO2Con Asia 2018] Talk Microservices to Me: The Role of IAM in Microservice...
 

Más de Chanaka Fernando

Más de Chanaka Fernando (17)

WSO2 API microgateway introduction
WSO2 API microgateway introductionWSO2 API microgateway introduction
WSO2 API microgateway introduction
 
Wso2 api microgateway deployment patterns
Wso2 api microgateway deployment patternsWso2 api microgateway deployment patterns
Wso2 api microgateway deployment patterns
 
Federated api management with wso2 api manager
Federated api management with wso2 api managerFederated api management with wso2 api manager
Federated api management with wso2 api manager
 
Wso2 enterprise integrator deployment patterns
Wso2 enterprise integrator deployment patternsWso2 enterprise integrator deployment patterns
Wso2 enterprise integrator deployment patterns
 
Api management best practices with wso2 api manager
Api management best practices with wso2 api managerApi management best practices with wso2 api manager
Api management best practices with wso2 api manager
 
Wso2 api manager analytics and reporting
Wso2 api manager analytics and reportingWso2 api manager analytics and reporting
Wso2 api manager analytics and reporting
 
Exploring ballerina toolset (docker, testing, tracing, analytics, and more) ...
Exploring ballerina toolset (docker, testing, tracing, analytics, and more)  ...Exploring ballerina toolset (docker, testing, tracing, analytics, and more)  ...
Exploring ballerina toolset (docker, testing, tracing, analytics, and more) ...
 
File processing and websockets with ballerina chanaka edited
File processing and websockets with ballerina chanaka editedFile processing and websockets with ballerina chanaka edited
File processing and websockets with ballerina chanaka edited
 
Hybrid integration platform reference architecture
Hybrid integration platform reference architectureHybrid integration platform reference architecture
Hybrid integration platform reference architecture
 
Wso2 esb-rest-integration
Wso2 esb-rest-integrationWso2 esb-rest-integration
Wso2 esb-rest-integration
 
Wso2 integration platform deep dive eu con 2016
Wso2 integration platform deep dive   eu con 2016Wso2 integration platform deep dive   eu con 2016
Wso2 integration platform deep dive eu con 2016
 
Wso2 esb-maintenance-guide
Wso2 esb-maintenance-guideWso2 esb-maintenance-guide
Wso2 esb-maintenance-guide
 
Advaced training-wso2-esb
Advaced training-wso2-esbAdvaced training-wso2-esb
Advaced training-wso2-esb
 
Wso2 con eu 2016 an introduction to the wso2 integration platform by chanak...
Wso2 con eu 2016   an introduction to the wso2 integration platform by chanak...Wso2 con eu 2016   an introduction to the wso2 integration platform by chanak...
Wso2 con eu 2016 an introduction to the wso2 integration platform by chanak...
 
Esb 4.9.0 release webinar
Esb 4.9.0 release webinarEsb 4.9.0 release webinar
Esb 4.9.0 release webinar
 
Wso2 esb 5.0.0 product release webinar
Wso2 esb 5.0.0   product release webinarWso2 esb 5.0.0   product release webinar
Wso2 esb 5.0.0 product release webinar
 
Introduction to WSO2 ESB Pass-Through Transport
Introduction to WSO2 ESB Pass-Through TransportIntroduction to WSO2 ESB Pass-Through Transport
Introduction to WSO2 ESB Pass-Through Transport
 

Último

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
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
 

Último (20)

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
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, ...
 
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
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
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
 
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
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
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...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
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
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 

Designing microservices platforms with nats

  • 3. The term microservices architecture refers to a distributed computing architecture that is built using a set of small, autonomous services that act as a cohesive unit to solve a business problem or problems
  • 4. Advantages of Microservices ● Build highly scalable applications ● Build robust applications that withstand failures ● Better utilization of computing infrastructure ● Helps innovation with reduced time to market ● Build modular systems that are easy to manage and maintain
  • 5. Characteristics of Microservices ● Independently deployable ● Design for failure ● Decentralized data management ● Domain driven design (finite scope per service) ● Agile development ● Container based deployments
  • 6. Challenges of Microservices ● Inter-service communication ● Observability ● Error handling and troubleshooting ● Security
  • 7. Inter-service communication for microservices ● Service Mesh based approach ○ Point to point communication ○ Become complex with the increase of microservices ○ Separate data plane and control plane ● Message Broker based approach ○ Fully decoupled communication ○ Complexity does not increase with the number of microservices ○ Subject based messaging
  • 9. NATS: Modern messaging framework that allows developers and operators to build distributed systems
  • 10. Why NATS? ● High performance: ○ NATS performs better than most of the existing message broker products, including Kafka and RabbitMQ. ● Lightweight: ○ It does not need sophisticated hardware and complex deployment models to support large message volumes. ● Simple to use: ○ It supplies a simple API to use the system. NATS has clients for over 30 programming languages. ● At most once and at least once delivery: ○ Supports message guarantees required by applications. ● Support for event handling: ○ It can handle event streams with better performance.
  • 11. NATS use cases ● Microservice-based applications: ○ Service mesh and inter-service messaging ● Event streaming applications: ○ Observability/analytics ○ Machine learning ○ Artificial intelligence ● Command and control-based systems: ○ Internet of Things (IoT) and edge computing ○ Telemetry/sensor data/command and control ● Augmenting or replacing legacy messaging systems
  • 12. How NATS work? ● NATS uses a subject based messaging model with a fully decoupled publisher and a subscriber ● Supports following message distribution mechanisms ○ Publish-Subscribe (topic based) ○ Request-Reply ○ Queue groups (load balancing) ● Messages are published on a subject and the consumers subscribe to the subject ● Wildcard subscriptions are allowed so that consumers can listen to messages from different subjects and different publishers
  • 13. NATS subject based messaging ● Supports wiretap messaging with wildcard “>” ● Multi character wildcard can be used to listen on a certain pattern of subjects ● Specific subject name is used to receive messages from specific publishers
  • 14. NATS request-reply messaging ● Publisher specifies a reply subject (inbox) ● Subscriber respond through the reply subject ● NATS can filter multiple responses and send the first (fastest) response
  • 15. NATS queue-groups messaging ● Publisher publishes on a subject. It is not aware of the queue group ● Subscribers form a queue group by specifying a common name for the queue parameter ● Messages are delivered to the subscribers in a load balanced manner
  • 16. NATS Clustering ● Helps scaling the NATS infrastructure according to the requirements of the application ● Clustering forms a fully connected server mesh. All nodes are aware of all the other nodes. ● Nodes are connected via sending simple messages (gossip) and does not require pre-configuration of all the nodes ● Messages are replicated to one of the adjacent node so that node failure does not cause a message loss ● Publisher and Subscriber can connect to different nodes (location transparency) to share messages ● Most applications can be supported with a 3-node cluster
  • 18. Microservices Inner-Outer Architecture ● Microservices does not exist in isolation. ● Inner Architecture deals with ○ Individual microservices ○ Inter-Service Communication ● Outer Architecture deals with ○ Integration with other parts of the enterprise platform ○ Governance of the microservices teams and processes ○ Shared services such as automation, infrastructure, observability
  • 20. Building an Outpatient Department (OPD) Application ● A hospital OPD unit performs various tasks related to patient care ● Patient Registration ○ Admit new patients to the unit and register them on the system ● Patient Inspection ○ A physician inspect the patient and decide on the next steps ● Patient Treatment ○ Based on the inspection, nurses take care of the temporary treatments including medication and doing various tests ● Patient Release ○ Once the temporary treatment is done, patient is discharged from the unit and send back home or admit to a long term ward for further treatments
  • 22. OPD Application Implementation ● Each microservice has its own database to store data related to that microservice ● Messages are used to share data between services ● Registration Service stores the patient details in the database and publish an event to the inspection service with the patient ID and token number ● Inspection Service listens to the event and do the inspection and update its database with inspection details. The required information is passed to the treatment service via an event. ● Treatment service receives the event and take actions accordingly and store the medication schedules and test results in its database. Once the patient is ready to be released, it sends a message via an event to the release service. ● Release service receives the event and discharge the patient and update its database.
  • 23. Securing Microservices ● Security for external communications ○ Client applications consuming the services ○ Different types of clients including mobile, web and standalone ○ Require advanced, standard security ○ OAuth 2.0 is becoming the de facto ○ API Gateways provides a standard mechanism to implement security ● Security for internal communications ○ Services communicate with the NATS server ○ NATS support basic authentication, key based authentication, JWT based authentication ○ Security can be implemented with TLS only since consumers are internal (trusted subsystem)
  • 24. Observability for Microservices with NATS ● Observability is a characteristic of the platform which defines how well the internal states of a platform can be inferred from the knowledge of its external output ● It is a responsibility of each component in the platform to implement enough observability through the external output such as ○ Log entries ○ Health check endpoints ○ Metrics endpoints ○ Application dashboards ● NATS supports observability through ○ Logging ○ Monitoring endpoints
  • 25. Implementing Observability for Microservices with NATS
  • 26. Implementing Observability for Microservices with NATS ● Microservices implements /healthz and /metrics endpoints to provide application statistics and status. ● Microservices publish logs to application specific log files ● NATS server has a separate log file and a set of endpoints to collect application statistics ● Prometheus collects application statistics from the endpoints of microservices and the NATS server and publishes to Grafana ● Promtail and Loki collects log entries and publishes to Grafana for visualization ● Grafana is used to create dashboards for microservices and NATS server monitoring and alert generation
  • 27. Microservices and Integration Platforms ● Enterprise platforms consists of heterogeneous systems that needs to be integrated. ● Microservices based applications are one such component in the overall architecture. ● Integration Platforms plays a pivotal role in enterprise by doing ○ Application Integration ○ Data Integration ○ B2B Integration ○ API Management ● Microservices needs to co-exist with Integration Platforms
  • 29. Microservices and Integration Platforms ● API-driven architecture is common within enterprise software platforms ● Services implemented at different layers based on their functionality and exposes APIs so that subsequent layers can consume ● Microservices can implement services at one of these layers or at core business functionality layer ● Microservices can integrate with other parts of the enterprise platform through the integration platform since it supports the interoperability and acts as the anti-corruption layer
  • 30. Future of Microservices and NATS ● Trends/Developments in Microservices domain ○ Service Mesh is becoming popular though most people still failing to use it ○ Usage of Saga pattern to implement transactional microservices ○ Serverless platforms provides easier approach to build microservices based applications ● What’s new in NATS? ○ JetStream is becoming popular for streaming use cases of NATS which requires advanced message delivery guarantees and persistence ○ NATS is used to build asynchronous logging frameworks and Service Mesh
  • 31. Future of Microservices and NATS ● Trends/Developments in Microservices domain ○ Service Mesh is becoming popular though most people still failing to use it ○ Usage of Saga pattern to implement transactional microservices ○ Serverless platforms provides easier approach to build microservices based applications ● What’s new in NATS? ○ JetStream is becoming popular for streaming use cases of NATS which requires advanced message delivery guarantees and persistence ○ NATS is used to build asynchronous logging frameworks and Service Mesh
  • 32. Learn More ● The book that contains more details can be found here https://www.packtpub.com/product/d esigning-microservices-platforms-wit h-nats/9781801072212
  • 33. Follow me Chanaka Fernando, Associate Director @ WSO2 Medium - https://medium.com/@chanakaudaya Twitter - https://twitter.com/chanakaudaya LinkedIn - https://www.linkedin.com/in/chanakaudaya Github - https://github.com/chanakaudaya