0% found this document useful (0 votes)
15 views46 pages

Microservices Architectural Patterns

The document discusses microservice architecture, which divides applications into small, independent services that can be developed and managed separately. It outlines the advantages and disadvantages of microservices, design patterns, communication methods, data management strategies, and best practices. Additionally, it includes case studies of successful implementations by companies like Amazon, Uber, and Netflix.

Uploaded by

karimi.amir96
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views46 pages

Microservices Architectural Patterns

The document discusses microservice architecture, which divides applications into small, independent services that can be developed and managed separately. It outlines the advantages and disadvantages of microservices, design patterns, communication methods, data management strategies, and best practices. Additionally, it includes case studies of successful implementations by companies like Amazon, Uber, and Netflix.

Uploaded by

karimi.amir96
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Microservice Architecture

Zahra Shakeri , Fatemeh Omidi


Content

Data Management and


Introduction
Transactions

Microservices Design Patterns PROJECT Advantages and Disadvantages

Design and
Case Study Implementation Principles
Microservices

A software architectural style where an


application is divided into a set of small,
independent services.
Each service:
• Is independently developed, deployed,
and managed.
• Performs a specific task or function.
• Communicates with other services via a
messaging system.
Advantages and Disadvantages

Advantages Disadvantages

• Easy to deploy • Lack of experience from the development

• High Availability team

• Microservices are the solutions to • Network Overhead

managing complex software system • Data Duplication

• Independent scaling using containers • Increase In Complexity

• Fault tolerant and better fault isolation • Higher monitoring and maintenance costs

• Reuse of microservices
Design and implementation principles
Communication and Messaging

Message
HTTP/REST
queues

Synchronous Asynchronous Event-driven


gRPC
Communication Communication systems

publish/subscri
GraphQL be patterns
Asynchronous Messaging Pattern

Event-driven
Message queues systems pub/sub patterns
• RabbitMQ • Kafka • Scalability
• Amazon SQS • Event streaming • Reducing
platform dependencies
• Guarantee message
reliability • Real-time data • Support for real-
time interactions
• Decoupling • High-throughput
communication
• Load Balancing
Message Queues

Message queues

• RabbitMQ
• Amazon SQS
• Guarantee message
reliability
• Decoupling
• Load Balancing
Even-Driven Architecture

Event-driven
systems
• Event streaming
platform
• Real-time data
• High-throughput
communication
Publish/Subscribe Pattern

pub/sub patterns
• Scalability
• Reducing
dependencies
• Support for real-
time interactions
Challenges in Communication

Latency

Network Failures

Data Consistency

Service Discovery
Best Practice For Communication

Use Consider Leverage


Fault
Lightweight Eventual API
Tolerance
Protocols Consistency Gateways

• Eventual Consistency • Implement Retries


• Strong Consistency • Circuit Breakers
Data Management in Microservices

Database Per
Service

• Choreography-Based Saga Shared


• Orchestration-Based Saga Saga Pattern database per
service

Event Sourcing CQRS


Database Per Services

Independent Data
Stores

Data Duplication
• Data Consistency

Data
Synchronization
Shared database per service

• It is suitable to start dividing a legacy


application into microservices.
CQRS

• For executing queries that require combined data


from multiple services.
Event Sourcing

• It is a design pattern that records


all system state changes as a
sequence of events.
• In this approach, the events that
lead to state changes are stored.
Saga Pattern
Choreography-Base Saga
Orchestration-Base Saga
Best Practice For Data Management

Use Event- Apply the Embrace


Automate
Driven Saga Eventual
Data Sync
Architecture Pattern Consistency
Common Microservices Architectural Patterns
Decomposition Patterns

Patterns for breaking down a monolithic system into smaller, more manageable services.

Benefits:
• Clear boundaries and ownership
• Enhanced modularity and scalability

Pattern:
• Decompose by Business Capability
• Decompose by Subdomain
• Decompose by Transactions
• Strangler Pattern
• Bulkhead Pattern
• Sidecar Pattern
Decompose by Business Capability

How do we decompose an application into small services logically?

Solution:
Decompose based on business capabilities that generate value for the
business
Decompose by Subdomain

What about God Classes?

Solution:
DDD (Domain-Driven Design)
Strangler Pattern

What about Brownfield?

Solution:
Gradually replace the monolith with
microservices, one domain at a time
Bulkhead Pattern

How to prevent failures?

Solution:
isolating elements of an application
into pools
Sidecar Pattern

What about peripheral tasks?

Solution:
attaching a helper service (the sidecar) to the main
Integration Patterns

Patterns for efficient coordination and communication between microservices and other systems.

Benefits:
• Manage service communication.
• Avoid complex dependencies.
• Ensure data transfer is efficient and secure

Pattern:
• API Gateway Pattern
• Aggregator Pattern
• Gateway Routing pattern
• Client-Side UI Composition Pattern
API Gateway Pattern

Managing multiple microservices, different data needs, and varying protocols

Solution:
Use an API Gateway as a single entry point for all requests.

Benefits:
Offloads authentication and authorization
Customizes API responses for different clients
Aggregator Pattern

how to collaborate the data returned by each service?

Solution:
Use an API Gateway as a single entry point for all requests.
Gateway Routing pattern

Clients need to manage multiple services, instances, or versions, requiring frequent updates

Solution:
Use application Layer 7 routing to route the request to the appropriate instances

Benefits:
Decouples clients from backend changes
Improves manageability, scalability, and deployment flexibility
Client-Side UI Composition Pattern

How to implement a UI screen or page that displays data from multiple services?

Solution:
Design UI as a skeleton with sections calling different microservices
Enables Single Page Applications (SPA) with dynamic UI updates
Observability Patterns

Observability design patterns considers tracking of logging, performance metrices and so.

Benefits:
• Provide clear visibility into system behavior
• Quickly identify errors and problems

Pattern:
• Log Aggregation
• Performance Metrics
• Distributed Tracing
• Health Check
Log Aggregation

How can we understand the application behavior through logs for a particular request?

Solution:
a centralized logging service
Performance Metrics

How should we collect metrics to monitor application perfomance?

Solution:
A metrics service is required to gather statistics about individual operations
Distributed Tracing

How to track scattered logs across multiple services?

Solution:
Log the Corelation ID
Health Check

how do you ensure a request doesn't go to failed instances?

Solution:
Each service needs to have an endpoint
that can be used to check the health
Cross Cutting Concern Patterns

deals with service discovery, external configurations, deployment scenarios etc.

Benefits:
• Unified implementation of infrastructure issues across all services
• Reduced code duplication.

Pattern:
• Externalized Configuration
• Service Discovery Pattern
• Circuit Breakers Pattern
• Blue-Green Deployments Pattern
Circuit breaker pattern

How do we avoid cascading service failures and handle failures gracefully?

Solution:
We can use circuit breaker pattern where a proxy service acts as a circuit breaker
Blue-Green Deployments Pattern

So how do we avoid or reduce downtime of the services during deployment?

Solution:
running two identical production environments, Blue and Green.
Case studies

Amazon

Success
Uber Netflix
Stories

Twitter
now X
Uber
Uber
Any questions?
Thank You

You might also like