Microservices architecture is an approach to developing a single application as a suite of small services that communicate with each other using lightweight mechanisms like REST APIs. Each service runs in its own process and communicates through APIs, allowing independent scaling of services. This contrasts with monolithic architecture where all application components are deployed together in one process. Microservices provide benefits like independent scalability, fault isolation, and faster development cycles compared to monolithic applications. Common technologies used in microservices include API gateways, service discovery, configuration management, distributed logging, and messaging.
2. What is Microservices Architecture?
Loosely
Coupled
Fine
Grained
Lightweig
ht
SOA
variant
Highly scalable,
resilient and
Configurable Design
Web/mobile/IOT Devices
Type
Format
Size
Registration
service
Visit Mgmt Service
Ordering Service
Rest API
(Req/Response)
API
Gateway
Microservice Architectural style is an approach to
developing a single application as a suite of small
services, each running in its own process and
communicating with lightweight mechanisms, often
an HTTP resource API.
Rest
API
Rest
API
Rest
API
Decomposition of
Business Concerns
based on DDD Principle
4. Microservice Vs Monolithic Architecture
https://i.pinimg.com/originals/03/19/8f/03198fb151de525f30d5d1073dfa039e.png
5. Why not Monolith?
UI
Appointment
Registration
Billing
App Server
Single
Database
Hard to understand and
modify
Overloaded web container
Development slowdown
Change requires full rebuild,
test and deploy
Single technology built design
Scalability Risk with data
growth
6. Why Microservices?
Small and Focused on one
Business Functionality (Domain
Driven Design)
Functional & Team Scaling
(Independent Development,
Release and Deployment)
Fault Isolation vs. Bring all down
Well defined Module boundaries
across domain functionalities with
explicit interface declaration
Polyglot Persistence
(Decentralized)
Rewrite can be limited to one
service
Compliance to NDHB Standards
Decentralized choreography vs
centralized orchestration
Loosely Coupled
Maintainability, Reliability,
Extensibility, Scalability
9. Microservices Architecture Ecosystem
• Business Microservices
• API Gateway
• Discovery Server
• Configuration Server
• Identity Management Server
• Authentication Server
• Logs Aggregator Server
• Logs Analyzer
• Admin Server
• Databases
• Message Queues
• Load Balancers
• Reverse Proxies
10. Microservices Architecture – Technology Framework
Technologies, frameworks ...
NetflixRibbon Used to implement client side load balancing. Spring cloud
config service
Used to provide centralized configuration for all
microservices
ELK Used to provide centralized logging in microservices
architecture
Zuul Gateway Used to provide public API routing
Sleuth Used to provide corelation id between inter-
microservice comunication
Consul Discovery service from Hashicorp with Spring Cloud
support.
Hystrix Communication resilience wrapper from Netflix
provides impl. for circuit breaker, timeout,
bulkheads, fallback, etc.
Resilience4J Communication resilience wrapper library that
provides impl for various resilient patterns
including circuit breaker, bulkheads, etc.
OpenFeign A HTTP client from Netflix that provides client side
load balancing, and can work with Hystrix.
Apache
HTTPClient
A HTTP client from Netflix that provides support for
basic resilience patterns like timeouts, retrys, etc.
12. Microservices Inter Service Communication Plan
A. Synchronous / HTTP calls
• API gateway to discovery server
• All to discovery server
• All to config server
• API gateway to identity management server
B. Asynchronous / Messaging
Microservice A to B through message queues (RabbitMQ,Kafka,Spring AMQP etc.)
C. Event-Sourcing
Microservices (e.g. A,B), Event Store, API Gateway, Message Bus
D. Event-Sourcing with CQRS
Microservices (e.g. A,B), Write /Read Event Stores, API Gateway, Message Bus
19. Microservice CQRS based Event Sourcing architecture – Patient
Registration
Patient Registration Microservice...
Responsibility: Manages Registration Processes
Owns: Patient Database
Responsibility: Looks up PHID from Person Health registry
Triggers: Patient event store
• User
Authentication
service
• Registration
service
• PHID Registry
Lookup Service
• Billing Service Responsibility: Manages Insurance Patient Registration
Owns – Billing database, Triggers – Bill Payment event store
• Update Patient
Service
• Merge/UnMerge
Patient Service
19
Business Entities
Person
Patient
Source of Payment
Facility
Care provider
Business Concerns
Walk in Patient Registration
Registration on Patient Portal
Update Registration
Link PHID with Hospital Registration
Number
Bulk Registrations
Merge Patient
Insurance Patient Registration
Responsibility: Updates Patient
Owns – Patient database, Triggers – Patient event store
Responsibility: Merges/Unmerges Patient
Triggers – Patient event store
Responsibility: Authenticates user and assigns system functionality based on
Roles and Permissions
Owns: User database
20. Microservice CQRS based Event Sourcing architecture – Patient
Registration
Patient Registration Microservice siness Entities ...
Staff
Roo
m
Bill
Business Concerns
...
Commands
CreatePatientCommand
UpdatePatientCommand
MergePatientCommand
UnMergePatientComman
d
LinkPHIDWithFacilityRegi
strationCommand
Events
PatientCreatedEvent
PatientUpdatedEvent
PatientMergedEvent
PHIDCreatedEvent
etc.
Queries
getPatientByCareProvide
r
getPatientBased
21. Microservice CQRS based Event Sourcing architecture – Visit
Microservice
Visit Microservice Entities ...
Staff
Room
Bill
Business Concerns
...
Commands:
CreatePatientEncounterCom
mand
UpdatePatientEncounterCo
mmand
ActivatePatientEncounterCo
mmand
DeactivatePatientEncounter
Command
PatientEncounterVisitCancella
tionCommand
CreateEpisodeCommand
ActivateEpisodeCommand
UpdateEpisodeCommand
DeactivateEpisodeCommand
Events
PatientEncounterCreatedEve
nt
PatientEncounterUpdatedEv
ent
PatientEncounterActivatedE
vent
PatientEncounterDeactivate
dCommand
VisitCancellationEvent
EpisodeCreatedEvent
EpisodeUpdatedEvent
EpisodeDeactivatedEvent
Queries
GetPatientEncounterByuniq
ueHealthIdentificationNumb
er
getAllPatientActiveEncoun
ters
getAllPatientDeactivatedEnco
unters
getPatientEpisodeByuniqueHe
althIdentificationNumber
getAllPatientActiveEpisodes
getAllPatientDeactivatedEpiso
des
getPatientCohortGroupsByDis
easeCode
26. THANKS!
Dr Pankaj Gupta
Head – ACCESS Health Digital
digital.health@accessh.org
Twitter: @pankajguptadr, @accesshdigital
LinkedIn: drpankajgupta, accesshdigital