Core Design Patterns for Micro Services-based Architecture
Since the beginning of software we all have been concerned to efficiently develop maintainable, scalable and performant systems that are future-proof and easy to change.
A major foundation for realizing this were different design patterns that became more widespread in software products regardless of programming language.
Throughout the last 15-20 years more specialized design patterns appeared in order to cope with architecture trends and different technologies such as patterns of enterprise application architecture to be used in SOA and other business process integration projects, security design patterns for high sensitive secured applications requiring end to end security and at last the more technology specific oriented to overcome technology limitations (the EJB design patterns for example).
But at the basis of all these patterns remained the Gang of Four (GoF) Design patterns used in applications on a wide scale over the years in different formats (as classical setup of classes) and most recently in a more concise form (as Lambda expressions in Java 8).
Now Micro Services are hot and although there are a lot of changes in comparison to older architectures the core, classical GoF patterns still play a role.
But before addressing them let's look at the past and identify things that this new architectural style has with older approaches in common.
First of all, if you developed a highly security sensitive application so far most of the time you had to audit actions performed by users in the various layers of that application. If you remember the design of an Audit Service with an underlying event store, then you can recognize the micro services trend in it.
If you think about SOA then you already see aspects related to concepts implemented that are similar to message brokers, asynchronous communications and with compensation jobs associated to those failure scenarios that could appear in an architecture that does not make use of distributed transactions, different transaction and resource managers and the two phase commit (2PC) protocol.
Some classical design patterns from the GoF collection play an important role in the micro services oriented architecture:
Adapter - in order to adapt services between different systems and stores and in order to adapt events from one type to another
Command - in order to execute necessary transformations and business operations across different services
Memento - in order to replay the occurred events on the objects to arrive at a certain business state for that object
Once again we can admire the beauty and the actuality of the GoF design patterns and ask ourselves what design patterns could be created today that would still be actual 20 years from now.