Architecture patterns are models influencing the full project structure. They are different than design patterns in a sense that design patterns tent to resolve a problem locally. A famous list of design-patterns can be found here.
Here we will list some of the most common architecture pattern (excluding DDD and micro-services pattern).
The layers architectural pattern helps to structure applications that can be decomposed into groups of subtasks, each of which is at a particular level of abstraction. Each layer provides services to the next higher layer. Services in a layer are implemented using services from the next lower layer.
- Clean dependencies (clear view what dependence on what)
- Improve reusability (each layer provide a new abstraction/service, allowing to replace elements in the upper-layers without changing the base.
- It can be tricky to have the upper-layers behaving as wanted if the under-layer are modified.
- Embedded devices because need of HW abstractions, etc...
In the Client-server architectural pattern, a server component provides services to multiple client components. A client component requests services from the server component. Servers are permanently active, listening for clients. The requests are sent beyond process and machine boundaries.
- Centralize services per servers, enforce strong cohesion.
- Each server can be considered as a standalone application, and its behaviour is independent of external influences besides the network itself.
- Different teams can work on different topics with no need to interact to each other.
- Applicable for network services
- Enforce clients to adapt to the server messaging pattern and adapt themselves to it.
- Domain with multiple players, where many need the same kind of information.
The Master-slave pattern supports fault tolerance and parallel computation. The master component distributes the work among identical slave components, and computes a final result from the results the slaves return.
- Scalability the application per design
- Fault tolerance
- Divide & conquer principle
- Slaves are isolated, they cannot share states between themselves
- Latency between the master & slaves not controllable
- Domain more oriented towards tooling. Need of specific requests/commands/executions are needed to scale (Hadoop, Spark, Jenkins, kubernets)
The Pipe-filter architectural pattern provides a structure for systems that produce a stream of data. Each processing step is encapsulated in a filter component. Data is passed through pipes. The pipes may be used for buffering or for synchronization.
- Work on data-streams
- Agnostic of the data-stream generator.
- Reusability & extendibility of the filters (to add & remove steps in the process)
- Filters can be developed stand-alone
- Behaviour is the combination of the different filters working on the data-stream
- Data-transformation overhead
- Gateways, data-analytics... (ex: Luigi, airflow, kafka)
The Broker pattern is used to structure distributed systems with decoupled components, which interact by remote service invocations. Such systems are very inflexible when components have to know each others’ location and other details. A broker component is responsible for the coordination of communication among components: it forwards requests and transmits results and exceptions.
Servers publish their capabilities (services and characteristics) to a broker. Clients request a service from the broker, and the broker then redirects the client to a suitable service from its registry.
- Dynamic changes, additions, deletions and relocations of objects possible
- One source of communication with/to. The broker define its interface
- Central component, needs to be robust & fast to work on the requests
- Connection of two worlds that does not really understand each other but need to interact to each other... (MQTT)
The Peer-to-peer pattern can be seen as a symmetric Client-server pattern: peers may function both as a client, requesting services from other peers, and as a server, providing services to other peers. A peer may act as a client or as a server or as both, and it may change its role dynamically.
- More oriented micro-service pattern. Each "node" is a stand-alone, getting requests and interacting with other nodes
- Self-organization approach
- No guarantee of quality of service
- Security difficult to guarantee at some extend: if not a trusted space
- Never really handle requests, but also need to ask other nodes requests that needs to be handle by them.
In the Model-View-Controller pattern, or MVC pattern (see Figure 3.13), an interactive application is divided into three parts: the model contains the core functionality and data, the view displays the information to the user (more than one view may be defined), and the controller handles the input from the user.
- For GUI, model does not depend on the number of views
- Views can be easily modified without changing anything else
- High complexity in the implementation to have a clear separation of concerns between each MVC elements. Existing frameworks should be used here.
- Synchronization issues between the different MVC constantly needed, even if nothing is happening.
- GUI, websites...
The Blackboard pattern is useful for problems for which no deterministic solution strategies are known. Several specialized subsystems assemble their knowledge to build a possibly partial or approximate solution. All components have access to a shared data store, the blackboard. Components may produce new data objects that are added to the blackboard. Components look for particular kinds of data on the blackboard, and may find these by pattern matching.
- New application easy to add
- Adding new data is easy
- Modifying data in the blackboard very difficult. May influence all applications added
- Big computing power needed (scale with the number of data contained in the board)
- More useful when you have pipes filling a big database (ex: no-sql database like cassandra) and you need to extract and work on some data.
- More applicable for application that needs a lot of data to perform. Such as deep-learning, etc...