Get started with microservices architecture

Sep 20, 2022 · 3 min read
Tanuki GitLab profile

A great way to jumpstart a DevOps practice is by adopting a microservices architecture. The benefits of a microservices architecture are numerous and include improved scalability, enhanced fault isolation, and the ability to bring new features to market faster.

How to start building with microservices architecture

Identify decomposable aspects of the application

One of the main properties of a microservice is its independence, so identifying the decomposable parts of the application — those parts that can work autonomously — is essential. Getting the service boundaries wrong could result in unwanted changes to other services, so you need to understand the system’s domain.

In many cases, such breakdown aligns with the business domains and is reflected in development teams.

Determine the metrics to monitor

With a microservices application, it’s crucial to monitor the status of each service so it’s possible to react to changing demands in the production environment. Some common metrics to monitor include the CPU and memory usage of each host, the API response time, and the error rate.

Without monitoring, teams may not catch problems when they arise. For example, if a server is overwhelmed by traffic, other services may not respond because they’re trying to communicate with an over-burdened service.

Being able to visualize these potential issues helps prevent downtime. Therefore, establish metrics early so necessary adjustments can be made as soon as possible.

Best practices for deploying and managing microservices

Infrastructure automation

When the number of microservices grows, an application can become difficult to manage. Each microservice has its own deployment schedule.

Some features are hidden behind feature flags, some are collecting usage data through A/B testing, and some services might be using Canary deployments as part of a progressive deployment.

Automated testing is key so teams will have the ability to stop or roll back deployment when necessary.

Consumer-driven contract tests

When other consumers depend on API endpoints in one microservice, it’s good practice to implement consumer-driven contract testing to ensure version compatibility.

Traditionally, developers first create the APIs on the server side and have clients determine which endpoints to call. That means when the signature of an API changes, it can bring down the consumer.

This can’t happen with consumer-driven contract testing because, before deploying a microservice to production, consumers determine the required contract (API signature) and test to be sure they are still valid.

Monitor key metrics

Once key metrics have been determined, they must be constantly monitored and able to respond to any events detected. This can be difficult, but fortunately, there are tools that simplify monitoring and provide comprehensive visualization.

Microservices architecture and DevOps

By decomposing a software system into autonomous parts, microservices architecture allows companies to apply the single responsibility principle to individual teams. It allows them to manage all aspects of a service independently: the team’s technical stack, team composition, deployment strategies, and even release schedules.

Microservices architecture, alongside continuous delivery, allows businesses to make decisions based on live production data, thereby expediting feedback loops and reducing the time to market.

To get started with microservices architecture, it’s a good idea to first develop strong intuitions in decomposing a large system and get a good knowledge base of CI/CD practices. Regardless of the architectural style you choose, these skills will be useful.

“Ready for the next DevOps step? Here's how to get started with microservices architecture” –

Click to tweet

Open in Web IDE View source