Skip to main content

Design Patterns

Design Patterns of Microservices

  1. Aggregator
  2. API Gateway
  3. Chained or Chain of Responsibility
  4. Asynchronous Messaging
  5. Database or Shared Data
  6. Event Sourcing
  7. Branch
  8. Command Query Responsibility Segregator
  9. Circuit Breaker
  10. Decomposition

https://www.edureka.co/blog/microservices-design-patterns

image

Functional Decomposition

Functional decomposition is a term that engineers use to describea set of steps in which they break down the overall function of a device, system, or process into its smaller parts. A function is simply a task that is performed by a device, system, or process. Decomposition is a process of breaking down.

https://en.wikipedia.org/wiki/Functional_decomposition- The Database per Service pattern describes how each service has its own database in order to ensure loose coupling.

https://microservices.io/patterns/microservices.html

Catalog of patterns

PatternSummaryCategory
AmbassadorCreate helper services that send network requests on behalf of a consumer service or application.Design and Implementation Operational Excellence
Anti-Corruption LayerImplement a façade or adapter layer between a modern application and a legacy system.Design and Implementation, Operational Excellence
Asynchronous Request-ReplyDecouple backend processing from a frontend host, where backend processing needs to be asynchronous, but the frontend still needs a clear response.Messaging
Backends for FrontendsCreate separate backend services to be consumed by specific frontend applications or interfaces.Design and Implementation
BulkheadIsolate elements of an application into pools so that if one fails, the others will continue to function.Reliability
Cache-AsideLoad data on demand into a cache from a data storeData Management, Performance Efficiency
ChoreographyLet each service decide when and how a business operation is processed, instead of depending on a central orchestrator.Messaging, Performance Efficiency
Circuit BreakerHandle faults that might take a variable amount of time to fix when connecting to a remote service or resource.Reliability
Claim CheckSplit a large message into a claim check and a payload to avoid overwhelming a message bus.Messaging
Compensating TransactionUndo the work performed by a series of steps, which together define an eventually consistent operation.Reliability
Competing ConsumersEnable multiple concurrent consumers to process messages received on the same messaging channel.Messaging
Compute Resource ConsolidationConsolidate multiple tasks or operations into a single computational unitDesign and Implementation
CQRSSegregate operations that read data from operations that update data by using separate interfaces.Data Management, Design and Implementation, Performance Efficiency
Deployment StampsDeploy multiple independent copies of application components, including data stores.Reliability, Performance Efficiency
Event SourcingUse an append-only store to record the full series of events that describe actions taken on data in a domain.Data Management, Performance Efficiency
External Configuration StoreMove configuration information out of the application deployment package to a centralized location.Design and Implementation, Operational Excellence
Federated IdentityDelegate authentication to an external identity provider.Security
GatekeeperProtect applications and services by using a dedicated host instance that acts as a broker between clients and the application or service, validates and sanitizes requests, and passes requests and data between them.Security
Gateway AggregationUse a gateway to aggregate multiple individual requests into a single request.Design and Implementation, Operational Excellence
Gateway OffloadingOffload shared or specialized service functionality to a gateway proxy.Design and Implementation, Operational Excellence
Gateway RoutingRoute requests to multiple services using a single endpoint.Design and Implementation, Operational Excellence
GeodesDeploy backend services into a set of geographical nodes, each of which can service any client request in any region.Reliability, Operational Excellence
Health Endpoint MonitoringImplement functional checks in an application that external tools can access through exposed endpoints at regular intervals.Reliability, Operational Excellence
Index TableCreate indexes over the fields in data stores that are frequently referenced by queries.Data Management, Performance Efficiency
Leader ElectionCoordinate the actions performed by a collection of collaborating task instances in a distributed application by electing one instance as the leader that assumes responsibility for managing the other instances.Design and Implementation, Reliability
Materialized ViewGenerate prepopulated views over the data in one or more data stores when the data isn't ideally formatted for required query operations.Data Management, Operational Excellence
Pipes and FiltersBreak down a task that performs complex processing into a series of separate elements that can be reused.Design and Implementation, Messaging
Priority QueuePrioritize requests sent to services so that requests with a higher priority are received and processed more quickly than those with a lower priority.Messaging, Performance Efficiency
Publisher/SubscriberEnable an application to announce events to multiple interested consumers asynchronously, without coupling the senders to the receivers.Messaging
Queue-Based Load LevelingUse a queue that acts as a buffer between a task and a service that it invokes in order to smooth intermittent heavy loads.Reliability, Messaging, Resiliency, Performance Efficiency
RetryEnable an application to handle anticipated, temporary failures when it tries to connect to a service or network resource by transparently retrying an operation that's previously failed.Reliability
Scheduler Agent SupervisorCoordinate a set of actions across a distributed set of services and other remote resources.Messaging, Reliability
Sequential ConvoyProcess a set of related messages in a defined order, without blocking processing of other groups of messages.Messaging
ShardingDivide a data store into a set of horizontal partitions or shards.Data Management, Performance Efficiency
SidecarDeploy components of an application into a separate process or container to provide isolation and encapsulation.Design and Implementation, Operational Excellence
Static Content HostingDeploy static content to a cloud-based storage service that can deliver them directly to the client.Design and Implementation, Data Management, Performance Efficiency
Strangler FigIncrementally migrate a legacy system by gradually replacing specific pieces of functionality with new applications and services.Design and Implementation, Operational Excellence
ThrottlingControl the consumption of resources used by an instance of an application, an individual tenant, or an entire service.Reliability, Performance Efficiency
Valet KeyUse a token or key that provides clients with restricted direct access to a specific resource or service.Data Management, Security

https://docs.microsoft.com/en-us/azure/architecture/patterns

Enterprise Application Architecture

  • Domain Logic Patterns: Transaction Script, Domain Model, Table Module, Service Layer.
  • Data Source Architectural Patterns: Table Data Gateway, Row Data Gateway, Active Record, Data Mapper.
  • Object-Relational Behavioral Patterns: Unit of Work, Identity Map, Lazy Load
  • Object-Relational Structural Patterns: Identity Field, Foreign Key Mapping, Association Table Mapping, Dependent Mapping, Embedded Value, Serialized LOB, Single Table Inheritance, Class Table Inheritance, Concrete Table Inheritance, Inheritance Mappers.
  • Object-Relational Metadata Mapping Patterns: Metadata Mapping, Query Object, Repository.
  • Web Presentation Patterns: Model View Controller, Page Controller, Front Controller, Template View, Transform View, Two-Step View, Application Controller.
  • Distribution Patterns: Remote Facade, Data Transfer Object
  • Offline Concurrency Patterns: Optimistic Offline Lock, Pessimistic Offline Lock, Coarse Grained Lock, Implicit Lock.
  • Session State Patterns: Client Session State, Server Session State, Database Session State.
  • Base Patterns: Gateway, Mapper, Layer Supertype, Separated Interface, Registry, Value Object, Money, Special Case, Plugin, Service Stub, Record Set

https://martinfowler.com/eaaCatalog/index.html

Self Contained System (SCS)

The Self-contained System (SCS) approach is an architecture that focuses on a separation of the functionality into many independent systems, making the complete logical system a collaboration of many smaller software systems. This avoids the problem of large monoliths that grow constantly and eventually become unmaintainable.

https://scs-architecture.org