Microservices is no longer a buzzword — it’s a routine architecture design in software development. To be more precise, it’s a go-to choice for cloud-native apps and SaaS solutions. Uber, Netflix, Amazon, eBay, and Groupon have been using this type of service-oriented architecture for years, helping it evolve into the powerhouse architectural solution it is today.

According to O’Reilly’s Microservices Adoption survey, in 2020 77% of software engineers said they had adopted microservices. A further 92% mentioned they had successful experiences with MS.

IBM’s 2021 report on Microservices in Enterprise provides further highlights, including that 88% agree on benefits of the architecture for the development team and 87% confirm that the effort and expense to adopt it is worth it.

If you need to know how to build microservices from scratch or evolve from a monolithic architecture,  the insider tips below will help ease you into this multi-layered process.

What Are Microservices?

One of the forefathers of microservices, Chris Richardson, celebrated the tenth anniversary of the concept on his Microservices.io site [a wiki for all things Microservices]. He recalls how he first mentioned it at a conference in Kyiv in April 2012, referring to it as a modular, polyglot architecture. Two years later, in 2014, the other founding proponents of MS, James Lewis and Martin Fowler, gave the concept a more commercial and pronounceable name. 

Ten years later, this is the common definition of microservices:

Microservices is a type of architectural framework in software development, where finely-grained function-specific services are language agnostic and can be individually deployed thanks to a loosely coupled API connection. 

This means that instead of the original monolith architecture, software solutions will be split into specific services [for example accounting, inventory, shipping, marketing], each of which are interconnected with the help of an API. This loose coupling allows the services to be developed independently from each other, eliminating the potential for a single point of failure. If there is an error in one of the services, it does not bring the entire solution down.

API Gateway call flow by AWS

What Are The Benefits Of Creating Microservices?

It may not be the perfect solution for a  one-size-fits-all approach, given the complexities associated with managing the services, inconsistency of data, testing intricacies, and technical debt, but microservices’ advantages far outweigh its minuses. These benefits include:

Scalability

Being able to scale up quickly and seamlessly without unreasonable spikes in cloud cost is critical for startups, especially those that serve B2B and B2C clients. Going from 1,000 users to 2,000 users may seem like a small increase, but its outcomes have snowball and ripple effects on the entire enterprise. Luckily, microservices can scale horizontally, vertically, and diagonally.

Resilience

One of the biggest luxuries in software development is having high availability — it’s also one of the major technical KPIs investors use to  judge a project. A failure or malfunction that takes place in one of the loosely coupled services in the frames of this structural style remains inside that service, while the rest of the functions are available to users.

Language Agnostic

Each microservice can be built in any language or preferred framework. This brings down the cost of the project, allows for innovative experiments, and offers added flexibility for the project’s development.

Faster Time to Market

As separate teams develop and deploy their services independently from each other with little effect on the entire system, they are in position to release new features faster with little coordination. CI/CD best practices are predominantly used with applications designed with microservices, so deployment and testing are often continuous.

Easy Deployment

Deploying individual self-contained services and features that function inside them is much easier than deploying a sizable monolithic architecture full of complexity.

Reusability of Code

Just as parents with two kids born with little age gap benefit from the same set of toys and books used by both kids, businesses opting for microservices can build services using code written for other modules. 

To reap above rewards, don’t rush to split your application into small services and connect them with APIs. Below we reiterate three cases when you definitely need to implement microservices. In other scenarios, you may want to consider monolith as the initial setup.

Reasons To Migrate To Microservices Architecture

While Microservices architecture is recommended for SaaS solutions, it’s not your only option, and there are certain pre-requirements for it to be selected. In our article on microservice orchestration, we elaborate on Sam Newman’s reasons to opt for MS architecture.

These are the three reasons Sam Newman singles out as the legit reasons to opt for a microservices architecture: 

  • Technical need for organizational autonomy & diversity of programming languages
  • Business need for high availability and zero downtime [all SaaS solutions, for example, and real-time apps for FinTech and SpaceTech]
  • Legal need for data partitioning due to compliance requirements in specific industries like FinTech, RegTech, HealthTech

If none of these cases fit your business scenario, you might want to consult Dev.Pro’s solutions architect about the right path of action in your case. Monolithic architecture has its set of benefits too.

How Microservices Work

At first, web portals and mobile applications ran on a monolithic architecture. As these applications grew more complex, developers found a way to create a more flexible, agile, and scalable structure for software solutions by splitting them by business function.

When building a microservice, solutions architects split all user, vendor, admin activities and business functions into self-contained modules. These include billing, reporting, order management, review engine, and foreign exchange calculators. 

These modules can then easily be built independently from each other, using the best programming languages and frameworks for this specific module. In bigger companies, different teams will develop and deploy different microservices with little notice about new feature releases and updates.

However, these business-oriented parts need to exchange data with each other. This seamless communication and functioning of the modules is due to the APIs that connect them and the individual servers that cater to the needs of each microservices.

On the server side, there is full freedom for each module. These modules may come in the shape of bare metal, be virtualized, hosted on the cloud, or containerized.

Microservices Architecture with Hybrid Deployment

How to Set Up a Microservices Architecture

There are dozens of ways of how to create microservices, all of them full of nuance. In a majority of cases, you will be working with a brownfield development. This means that you will have some part of the solution that is based on legacy code, most with some of the bare metal on-prem servers as well.

Greenfield projects allow you to convert those discovery and design phases of the SDLC into a real ROI booster, as you have the freedom to pick any languages, frameworks, CSP, decomposition methods, or communication patterns. You can also build it in a cloud-native manner, have a few scaling scenarios according with the best FinOps practices, and integrate testing and security earliest for faster time-to-market and high resilience.

However, as it stands in 2022, at least three quarters of all solutions will have some portion of a legacy system to them, which requires a brownfield approach. Let’s consider some of the milestone steps on this mission that also contain microservices architecture best practices.

1. Conduct Full Audit of Business Requirements & Market Research

Understanding the business purpose, market, and monetization models of the software you are about to create will help you get its technical embodiment right from the start.

Get every document, plan, draft, pitch deck, and roadmap available with founders and major stakeholders to get the PM, solution architect, BA, and DevOps team onboard.

2. Conduct an In-Depth Inventory of Resources: Systems, Team, and Budgets

If you are picking up a project for cloud migration or building a cloud-native multi-platform SaaS application, get an overview of all available means to accomplish your mission. Now that you know the destination of your project, you need to have a thorough understanding of your starting point and available resources.

Request all available tech docs, inventory the current tech stack, review the team members and their skill set, and consider the budgetary expectations of the product owner.

3. Connect the Status Quo and Vision in Design

Once you have familiarized yourself with point A and point B, it’s time to map the journey. Business analytics and the project manager will provide and consolidate all documentation to enable the work of a solutions architect. 

These technical decisions are to be addressed by the person in charge of designing microservices:

4. Decide on decomposition pattern

You can split your services according to different verticals and aspects, including:

By business function 

[order management and client management]

By subdomain 

[delivery management and inventory management modules]

Strangler decomposition 

[2 apps – the old and the new versions live side by side until the new one is ready to substitute the older one, going through the stages of transformation, coexistence, and elimination]

Bulkhead decompositioning 

[ services are isolated into groups based on availability requirements and service functions, so a failure (if it occurs) is limited to a specific group of services]

Self-contained services

[creating a self-contained service that can function without response from other services]. Alongside the service-per-team concept, this decomposition principle is rather amateur.

5. Choose a Method of Communication Between Microservices

There are a few major communication protocols that are used by facilitators that send messages between services, servers, or queue them for procession.

There are 3 main types of communication, where all messaging happens synchronously and may cause bottlenecks in the system, overheated with requests, or where messages line up in a queue, waiting to be processed. This second asynchronous type of communication ensures better distribution of the data exchange in moments of high traffic.

Type of Microservices Communication:

  • Synchronous
  • Asynchronous
  • Publish / Subscribe

Bigger software solutions may use a hybrid communication approach, queueing some of the services and enabling one-to-one direct message exchange between other components.

6. Arrive at the Best Database Management Method

The two major methods being Database per Service and Shared Database approaches.

For bigger microservice-based projects with lots of data having an individual database per each service is a non issue — hardly any capacity is wasted due to the scale of the project. This is not the case for smaller solutions, where a smaller microservice may have insufficient data to use up all of the capacity of an assigned DB, wasting the resource.

Another advantage of this DB management method is that you can choose the exact type of database needed for this specific function. You can choose between non-relational and relational, as well as graph databases and object-oriented ones. You can also mix and match the suppliers based on how often you use specific data and how critical high availability is for its extraction.

A plethora of other technical decisions have to be made to produce an architecture that is aligned with the business requirements, current status and the resources, for example: service discovery, API connections, deployment patterns, and cloud service models.

7. Procure All Necessary Tech Solutions and Retire the Discarded Ones

Once all technical decisions are considered and laid out in a project architecture plan, it’s time to procure the missing technical tools for the first stages of the processes. This step is followed by integration and configuration stages, so that all systems are interlinked and ready for creating a microservice.

Some of the basic tech you will need to procure, configure and integrate includes:

  • Cloud Services [AWS, GCP, AZure]:  you can go for a combination of vendors and will need to select the best tools for a myriad of submissions
  • MQ: Kafka & RabbitMQ are the most popular
  • DevOps & conterization: Kubernetes, Docker
  • DataBases: NoSQL [MongoDB, Cassandra] or/and RDBMS [MtSQL, Oracle]
  • Frameworks [Spring boot, Micronaut, Oracle Helidon, GoMicro, Flask, Spark, Qaurkus]

8. Start with Development, Testing, Deployment or Migration

Depending on your starting point, the steps from here on may differ, as you may need to be migrating from cloud using either refactoring, shift and lift, replatforming or other methods. Or you could be manning a fresh team to build a web portal or an application from scratch.

Managing Microservices can be a rather technical mission if you ensure the consistency, technical agility, and premeditated approach at the stages of migration or architecture design.

Best Practices For Microservices Architecture

When brooding over how to build microservices you may consider taking some of these industry lessons into account:

  1. Use team members’ strengths to build microservices around them.
  2. Consider asynchronous communication for a looser coupling.
  3. Mold your teams in a compact manner on a two-pizza rule for best agility & efficiency
  4. Use a service mesh layer for inter-service communication on larger applications.
  5. Facilitate deployment by using containers.
  6. Use a Database per Microservice approach for less complexity in data management and team collaboration.
  7. Use API gateway to avoid bottlenecks and hot spots in messaging and communications.
  8. Automate deployment process employing best CI/CD practices and leading industry DevOps tools like Jenkins.
  9. Consider downstream services, like DB, queues, and file systems for disaster recovery.
  10. Centralize your logs for better observability using your main CSP tools or third-party solutions like Prometheus and Grafana.
AWS logging capabilities

Microservices best practices evolve alongside the industry, so our certified cloud engineers and solution architects keep a close eye on all new developments.

Check out other insights on the topic with latest insider tips:

If you have a question that is not covered in the article, feel free to schedule a free 15-minute consultation with our engineers on the technical problem you are trying to address.

Afterword: How to Build Microservices For High Availability

Monolith is still a thing. Before you even start considering decoupling your software, make sure you really need to take this path — it’s not a walk in the park, but the benefits are worth the tradeoffs in the right cases.

Microservices management is a complex mission that you can simplify significantly at the design and build phases.

Looking for a cloud migration consultation? Need a second opinion on the refactoring succession? Dwelling on the best tech stack for your monitoring and alerting tasks? Not sure if you should go with a shared database or single DB per service? Talk to our team to gain professional insights and answers.

FAQ on How to Build Microservices

What are the 3 C’s of Microservices?

The 3 C’s of Microservices are: 
Componentize [splitting of a monolithic application into components]
Collaborate [teams working on services, DevOps, Security need to work in close collaboration, as well be compact as individual units for agility]
Connect [whether using proxy or API, interconnecting the microservices between each other, database and message broker is mission-critical]

What are the Best Languages For Microservices?

Java, Node.js, GoLang, .Net, Python are all popular programming languages used for building web applications with a microservices architecture. Using Docker and Kubernetes is one of the best practices for microservices when it comes to DevOps, while Kafka and RabbitMQ are commonly used for messaging.

FinTech White Paper