Microservice Flex Patterns
Tags: softwarearchitecture, enterprisetechnology, kubernetes, microservices
Published: 2019-04-23 10:50:18

---
title: Microservice Flex Patterns
published: true
tags: software-architecture,enterprise-technology,kubernetes,microservices
canonical_url: https://medium.com/humanitec-developers/microservice-flex-patterns-a6d852a5eadc
---

There are numerous approaches and patterns for microservice architecture.  What I'd like to do here is document a few of the more popular loosely coupled architectures and how to combine them into a single more flexible implementation. 

To get a better idea of how this works lets first review a few of the more popular MicroService patterns many developers use and how they can be implemented.

![](https://cdn-images-1.medium.com/max/1024/0*9Yk7n404OfgCYc4m.png)<figcaption><em>Proxy Design pattern as implemented in the Humanitec BiFrost core.</em></figcaption>

The proxy pattern provides a single url endpoint along with basic authentication and authorization across multiple end points. This pattern gives the Frontend or client developers a single URL and endpoint to manage for all data requests. It can also be extended to provide pass-through authentication via a token auth process like JWT that provides basic authentication to each Microservice.

![](https://cdn-images-1.medium.com/max/1024/0*DSdTwNu0OM9n-pM9.png)<figcaption><em>Aggregator Design pattern as implemented with the Humanitec BiFrost core</em></figcaption>

An extension to the proxy pattern is the aggregation design pattern. This common pattern usually uses a tool like GraphQL at it’s center and allows you to aggregate all or parts of your end point data in one gateway service as a data query tool. This allows for decoupled services while still providing a single URL through a gateway for each service. It’s also provides Frontend developers with one endpoint to query each of the Microservice endpoints as well as perform basic linking or aggregating of the data. In our case we provide a data grid tool that uses Swagger docs to create a simple REST API data mesh for all the related endpoints and allows the developers to pre-configure the desired join queries and cache levels.

![](https://cdn-images-1.medium.com/max/1024/0*2XzT1Wp5aAhzGFhs.png)<figcaption><em>Asynchronous Design patter as implemented in Humanitec’s BiFrost core.</em></figcaption>

The Asynchronous design pattern can be used with a gateway or not, but each Microservice can publish data to a messaging queue like RabbitMQ and subscribe to the data it needs from other services. This requires a bit more upfront configuration for each service but provides the needed data and only the needed data to each end point and can help to reduce query time compared to an aggregation service.

![](https://cdn-images-1.medium.com/max/1024/0*hO7HBy7zYCszoE3_.png)<figcaption><em>Humanitec BiFrost Flex Pattern</em></figcaption>

A Microservice Flex Service plattern (a term we came up with at [Humanitec](https://www.humanitec.com) after building it into our Walhall platform) allows the developers of each service to choose how they want to share data, either via a messaging Queue or Gateway and API data aggregation, or a fully decoupled backend for frontend pattern. An example is our BiFrost service that provides a simple way to use “workflows” as unique identifiers via UUID’s that are generated in BiFrost models and that can be registered with the core service and each related service entry, then used as a lookup table/service between entries in each backend service endpoint.

![](https://cdn-images-1.medium.com/max/571/0*swVrLpLX9nYshejD.png)<figcaption><em>BiFrost and the data mesh</em></figcaption>

The Flex pattern does not require the developer to subscribe to a particular pattern upfront because all the needed services are running in the BiFrost core. This way depending on the use case, type and shape of the data coming into a service developers can choose how to implement each microservice in the optimal way for that service. The only requirement is that each service provides an [OpenAPI](https://www.openapis.org/) swagger doc for each service. This helps ensure a standard style and practice for each API service, but also allows us to aggregate the service where needed into the gateway and data mesh.

These services also allow a developer to create lookup service as join tables for data across Microservices where needed and apply flexible centralized role based permissions for them as well. It gives you the developer a lot of flexibility to design an application the way you want, decouple and part out the work where you want and focus on the building of innovative and flexible applications.

_Originally published at_ [_humanitec.com_](https://humanitec.com/blog/microservice-flex-patterns)_._

* * *