Micro Service
Micro Service
Mizanur Rahman
2
The microservice architecture enables the rapid, frequent and reliable delivery of large,
complex applica6ons. It also enables an organiza6on to evolve its technology stack.
3
Micro-Services Architecture
• Defined as:
functional system decomposition into manageable and
independently deployable components
• Dealing with distributed systems’ development, deployment, and opera6onal management overheads can be
expensive requiring a high ini6al investment to run.
• Choosing a different tech stack for different components leads to non-uniform applica6on design and
architecture.
• Endless documenta6on in the form of updated schemas and interface documents for every individual
component app.
• The costs of maintenance, opera6onal costs, and produc6on monitoring are much higher, and the la^er also
suffers from a dearth of available tools.
• Automa6on tes6ng becomes difficult when each microservice component is running on a different run6me
environment.
• Increased resource and memory consump6on from all the independently running components which need
their own run6me containers with more memory and CPU.
• Microservices, when implemented incorrectly, can make poorly wri^en applica6ons even more dysfunc6onal.
7
Monolithic architecture
Problems of Monolithic Architectures
• Code complexity and maintainability
• Deployment becomes the bottleneck
• Fear to change
• Lack of ownership
• Failure dependencies
• One size doesn’t fit all (ex: relational DB)
• Hard to scale out
Monolithic
Micro Services
Quality Characteristics
Cont…
Decomposition
• as per uncle bob , we follow the circular journey of
•
16
Decomposition benefits
• focuses on CI/CD and, Simplifies testing and enables components to deployed independently,
• service must be small enough to be developed by a small team and to be easily tested.
• Focusing on SRP (Single Responsibility Principle) & Common Closure Principle (CCP), which states that classes that change for the same reason should be in
the same package
•
17
Decompose by subdomain
Define services corresponding to Domain-Driven Design
(DDD) subdomains. DDD refers to the applica6on’s
problem space - the business - as the domain. A domain is
consists of mul6ple subdomains. Each subdomain
corresponds to a different part of the business.
• Private-tables-per-
service – each service
owns a set of tables
that must only be
accessed by that
service
• Schema-per-service –
each service has a
database schema
that’s private to that
service
• Database-server-per-
service – each service
has it’s own database
server.
•
23
Transactional messaging
31
Testing
Deployment patterns
Deployment patterns
34
Communication style
Remote Procedure Invocation (RPI)
- REST
- gRPC
- Apache Thrift
Messaging
- Apache Kafka
- RabbitMQ
Domain-specific protocol
Other services:
etcd
consul
Apache Zookeeper
40
Observability
• Log aggrega6on
• Applica6on metrics
• Audit logging
• Distributed tracing
• Excep6on tracking
• Health check API
• Log deployments and changes
45
Service Mesh
46
Recommended Read