Introduction
The following is an subset of software architecture patterns, which tend to be referenced when academic discussions around patterns arise. The following are my comments.
Patterns
Application Architecture
Microservice
The microservice pattern comes from domain-driven design where in particular the concept of bounded context came to be the decoupling of services. The post Microservices by Martin Fowler also played a large part in naming this pattern.
Drivers:
- Loosely coupled with other services – enables a team to work independently the majority of time on their service(s) without being impacted by changes to other services and without affecting other services
- Independently deployable – enables a team to deploy their service without having to coordinate with other teams
- Capable of being developed by a small team – essential for high productivity by avoiding the high communication head of large teams
- The application must be easy to understand and modify
- You must run multiple instances of the application on multiple machines in order to satisfy scalability and availability requirements
- You want to take advantage of emerging technologies (frameworks, programming languages, etc)
Problems:
- Managing dependencies
- Deployments of the entire system may become complex
- Developers must implement the inter-service communication mechanism and deal with partial failure
- Implementing requests that span multiple services is more difficult
- Testing the interactions between services is more difficult
- Implementing requests that span multiple services requires careful coordination between the teams
Database
Database per Service
This pattern is basically the natural follow-on to choosing the microservice application architecture pattern, where if a service is to become independant, then it must have it’s own independant data layer.
Drivers:
- Services must be loosely coupled so that they can be developed, deployed and scaled independently
- Databases must sometimes be replicated in order to scale
- Different services have different data storage requirements, like relational database or NoSQL
Problems:
- How to manage consistency across services
- Who owns (masters) data?
Messaging
Messaging is a communications pattern which uses asynchronous messaging to replace the synchronous style of request/response used in most REST-style APIs. Most common styles of asynchronous messaging are:
- Notifications – a sender sends a message a recipient but does not expect a reply. Nor is one sent.
- Request/asynchronous response – a service sends a request message to a recipient and expects to receive a reply message eventually
- Publish/subscribe – a service publishes a message to zero or more recipients
- Publish/asynchronous response – a service publishes a request to one or recipients, some of whom send back a reply
In the following there’s no differentiation between “event”-driven and “data”-driven, as a message will always contain the full message body.
Event Driven with full Messages
Drivers:
- The complete body of the message must be sent in each event
- The broker may or may not allow for queries against the messages
- Extreme loose coupling as the sender is completely decoupled from the receiver
Problems:
- Subscriber/consumer overload which requires buffering so that events are not lost
- The broker/mediator must always be available
- Almost always creates mixed messaging styles with events for downstream and request/response across and upstream which requires carefull planning
Broker
Event driven messaging with a broker implies that all messages are delivered through a central broker but that there’s no processing control flow and messages are delivered using a publish/subscribe pattern.
Drivers:
- Scalability
Problems:
- How to handle orchestration? With “normal” synchronous request/response messaging services orchestrate business processes in the order that they are called – with broker driven messaging everybody potentially could get the same message at the same time, so who orchestrates the overall process?
Mediater
A mediater expands on the broker with support for business process workflows usually with support for BPEL.
Drivers:
- Business processes change often
- Traceability and governance is important
Problems:
- Management and governance of platform takes time
- Requires turnkey solutions from major vendors
- Not really available as a cloud solution
Event Driven with Notifications
Drivers:
- You don’t know how many subscribers/consumers of your events there will be, so you must preserve bandwidth
- The size of the payload in the event is limited
- A subset of the events doesn’t require the complete body of the message to be sent
- Subscribers explicitly want to chose which message bodies they want to pull
Problems:
- Requires a two-step dance where the consumer of an event must issue a request to the central broker and ask for the full body of the message