Posted on: Monday, 8 Aug 2022

Distribute Monolith Vs. Microservices

DevOps practices and culture have led to a growing trend of dividing monoliths into microservices. Despite the efforts of the organisations involved, it is feasible that these monoliths have evolved into “distributed monoliths” rather than microservices. Since You’re Not Building Microservices argued that “you’ve substituted a single monolithic codebase for a tightly interconnected distributed architecture” (the piece that prompted this one).

It is difficult to determine whether your architecture is distributed monolithic or composed of several more minor services. It’s essential to remember that the answers to these questions may not always be clear-cut exceptions—after all, the current software is nothing if not complicated.

 

Let’s understand the definition of Distributed Monolith:

Distributed Monolith resembles microservices architecture but is monolithic. Microservices are misunderstood. Not merely dividing application entities into services and implementing CRUD with REST API. These services should only communicate synchronously.

Microservices apps have several benefits. Creating one may result in a distributed monolith..
Your microservice is a distributed monolith if:
● One service change re-deploys additional services.
● Microservices need low-latency communications.
● Your application’s tightly connected services share a resource (like a database).
● Microservices share codebases and test environments.

 

What is Microservice Architecture

Instead of constructing a monolithic app, break it into more minor, interconnected services. Each microservice has a hexagonal architecture with business logic and adapters. Some microservices expose REST, RPC, or message-based APIs, and most services consume them. Microservice architecture affects the application-database connection. It duplicates data. Having a database schema per service ensures loose coupling in microservices. Polyglot persistence design allows a service to use the best database for its needs.

Mobile, desktop, and online apps use some APIs. Apps can’t access back-end services directly. API Gateways mediate communication. The API Gateway balances loads, caches data, controls access, and monitors API usage.

 

How to Differentiate Distributed Monoliths and Microservices

Building microservices is our goal. Sometimes implementation turns an app into a distributed monolith. Bad decisions or application requirements, etc. Some system attributes and behaviors can help you determine if a system has a microservice design or is a distributed monolith.

 

Shared Database

Dispersed services that share a database aren’t distributed—distributed monolith. Two services share a datastore.

A and B share a datastore. Changing Service B’s data structure in Datastore X will affect Service A. The system becomes dependent and tightly connected.

Small data changes affect other services. Loose coupling is ideal in a microservice architecture. Use case: If an e-commerce user table’s data structure changes. It shouldn’t affect products, payments, catalogs, etc. If your application redeploys all other services, it can hurt developer
productivity and customer experience.

Codebase/Library

Microservices can share codebases or libraries despite having distinct ones. Shared library upgrades can disrupt dependent services and require re-deployment. Microservices become inefficient and changeable.
Consider using a private auth library across services. When a service updates the auth library, it forces all other services to redeploy. This will create a distributed monolith program. An abstracted library with a bespoke interface is a standard solution. In microservices, redundant code is better than tightly connected services.

 

Sync Communication

Coupled services communicate synchronously.

If A needs B’s data or validation, it depends on B. Both services communicate synchronously. Service B fails or responds slowly, harming service A’s throughput. Too much synchronous communication between services can make a microservice-based app a distributed monolith.

 

Deployment/test environments shared

Continuous integration and deployments are essential for microservices architecture. If your services use shared deployment or standard CI/CD pipelines, deploying one service will re-deploy all other application services, even if they haven’t changed. It affects customer experience and burdens infrastructure. Loosely linked microservices need independent deployments.

Shared test environments are another criterion—shared test environments couple services, like deployments. Imagine a service that must pass a performance test before production. This stage tests the service’s performance. Suppose this service shares the test environment with
another that conducts performance tests simultaneously. It can impair both services and make it challenging to discover irregularities.

To sum up

Creating microservices is more than simply dividing and repackaging an extensive monolithic application. Communication, data transfer across services, and more will have to be changed for this to work.

Related Blogs

Cloud Myths
11 Common Myths About Adopting...

Cloud technology is in the mainstream today. It has experienced...

Read more
Disaster Recovery & IAC (Infrastructure...

The term "Infrastructure as Code," or IaC, has been gaining...

Read more
Top Cloud Mistakes That Will...

Cloud Computing is a rage today. More and more companies...

Read more
Why API Gateway is Important?

An application programming interface, or API gateway, sits between a...

Read more
Cloud Migration Strategy – What...

There’s no one-size-fits-all answer when it comes to cloud migration....

Read more
What Is API First Approach...

Application Programming Interfaces, or Web APIs, have been present for...

Read more
Is Cloud Cheaper in the...

The concept of "the cloud" refers to more than simply...

Read more
Multicloud Adoption Challenges And Best...

Cloud adoption has been a slow process for many organizations,...

Read more
Application Modernization Patterns And Antipatterns

In today’s times, modernization is imperative for organizations and businesses....

Read more