Microservices Design Guide - Platform Engineer - Medium
Microservices Design Guide - Platform Engineer - Medium
Microservices Concept
Microservices architecture consists of collections of light-weight,
loosely-coupled services. Each service implements a single business
capability. Ideally, these services should be cohesive enough to
develop, test, release, deploy, scale, integrate, and maintain
independently.
Formal Definition
• Each service can pick the best technology stack for its use cases
(no need to stick into one framework throughout the entire
application).
• Each service has its own DevOp plan (test, release, deploy, scale,
integrate, and maintain independently).
• Each service is responsible for persisting its own data and keeping
external state (Only if multiple services consume the same data,
such situations are handled in a common data layer).
Benefits of Microservices
Microservice are made to scale large systems. They are great enablers
for continuous integration and delivery too.
The Scale Cube: 3-Dimensional Model for Scalability (Image: Nginx Blog)
• Independent scaling — Microservices architecture supports Scale
Cube concept described in the excellent book The Art of Scalability.
When developing microservices to achieve functional
decomposition, the application automatically scales via Y axis.
When the consumption is high, microservices can scale via X axis
by cloning with more CPU and memory. For distributing data
across multiple machines, large databases can be separated
(sharding) into smaller, faster, more easily managed parts
enabling Z axis scaling.
Operational Concerns
Independent services alone cannot form a system. For the true success
of microservices architecture, significant investments are required to
handle cross-system concerns like:
. . .
API Gateway acts as a single entry point for all clients as well as an
edge service for exposing microservices to the outside world as
managed APIs. It sounds like a reverse proxy, but also has additional
responsibilities like simple load-balancing, authentication &
authorization, failure handling, auditing, protocol translations,
and routing. The development team can select one of the following
approaches to implement an API Gateway.
. . .
Best Practices
✅ Domain Driven Design — Model services around the business
domain.
To handle large models and teams, Domain Driven Design (DDD) can be applied. It deals with large
models by dividing them into di erent Bounded Contexts and being explicit about their
interrelationships and underling domain. These bounded contexts can be converted into separate
microservices at the application design level (Read: Bounded Context in Domain-Driven Design).
Avoid shared data stores and data access mechanisms (Image: christianposta.com)
. . .
Microservices in Practice
When to use Microservices
Microservices architecture best fits for:
• Applications with high scalability needs
Deployment Options
• Containers — good for enforcing DevOp objectives (rapid
development, reduced time to market, seamless scaling)
. . .
Architecture Suggestions
Microservices architecture for an online shopping application (Image: microsoft.com) — This architecture is proposed by Microsoft developers using Microsoft
technologies. Here, the API Gateway has been tailored to treat web and mobile users di erently. For data layer, data store technologies are carefully selected
according to the business capabilities (relational databases for structured data, Redis for temporary data caching, MongoDB and CosmosDB for unstructured
data). Interservice communication handled by the event bus. Keeping technologies aside, this is the most common integration pattern used in microservices-
based applications.
Microservices architecture for an application which displays realtime updates to end users using large amounts of input data streams coming from various
event sources (e.g. tra c data, weather readings, stock market feeds, social media posts, sensor outputs). These input data streams are initially collected by an
event log implemented using Ka ka. It persists data on disk and thus can be used for batched consumption purposes (analytics, reporting, data science, backup,
auditing) or sent for real time consumption purposes (operational analytics, CEP, admin dashboards, alert apps). However, according to this diagram, the
continuous incoming stream is divided into micro-batches with speci ed intervals using Spark and fed into the WSO2 Siddhi CEP engine. Then it identi es the
events and persists them in unstructured forms using MongoDB data stores. Microservices consume these data and display to the end users. If you carefully
look at the design, since Vert.x event bus has the ability to create connections with frontend UI components, that feature has been used to e ciently update
only the relevant parts in the UI. Keeping technologies aside, this is a great architecture for event-driven non-blocking microservices-based application.
Cloud native omni-channel microservices architecture for an order management application (Image:
ibm.com) — One major specialty in this design is, instead of using an API Gateway, IBM architects
have proposed an edge layer with separate backends for each clientside channel (mobile apps, web
apps, IOT devices, API consumers). Another specialty is that the microservices layer is divided into 2
sub layers called Business Logic layer and Foundational layer. Foundational Layer (a.k.a. Core Services
Layer) deals with persistence and integration tasks using various cloud native services (cloud data
stores, Elasticsearch engines that integrate and index a Watson conversation). Business Logic layer
integrates data from Foundational layer and delivers meaningful business capabilities. This would be
a great architecture for serving very high number of user base who are geographically-dispersed and
access to application via various platforms.
. . .