Transition from a monolithic application to microservices
Tags: webdev, microservices, deployment, architecture
Published: 2020-03-13 11:02:16

---
title: Transition from a monolithic application to microservices
published: true
description: A discussion about software architecture and transition from a monolithic app to microservices 
tags: web dev, microservices, deployment, software architecture
cover_image: https://nordicapis.com/wp-content/uploads/Monolith-vs-Microservices.png
---
Software development is not just about writing coding on IDE and runs that code to get the result, writing code is the last step you can do especially if you are developing a backend application.

Writing web applications is super easy if you are building a traditional web app that gets data from the database and does some processes and then renders HTML content to the browser as a response, this was the traditional and the old way of building web applications. Everything has changed since the javascript frameworks revolution, new frameworks and libraries are introduced for frontend developers such as angular and react, this made your codebase is separated between frontend and backend, your backend now is focusing on the complex logic, database and replacing HTML responses with JSON response.

This is the start for building REST APIs that can be consumed from different types of users and clients such as frontend apps, mobile apps event other backend apps.
Now everything is cool, you are now free from the monolithic app!!
Yes, your code now is distributed on client apps such as browser apps or mobile and your backend but will happen if your backend is consumed heavily and your database became large and it's not possible to exist on a single machine?

Here microservices come to solve your issues but how?
![alt](https://blog.kohactive.com/content/images/2018/11/monolith_microservices.jpg)

Maybe you thought that your application now is not a monolithic app, but the reality is that it was a step to freedom from the monolithic app, but you still on the same row.

Inside your application, you still have one app that serves all kind of users and requests with one database, however, you can distribute your code on different machines and systems to keep your backend extensible and easy to maintain and develop.

How does this happen?
Imagine that you are building a social media app that includes admin portal to manage the app, mobile app, and web app, also you have different types of users such as admin and user, also have different types of actions and functionalities like Facebook, you have videos, images, posts, followers, followings, pages, ads and more, How you can handle all that in a single codebase, backend, and machine!!

Absolutely it's impossible to develop, maintain, monitor and test all these functionalities in single backend codebase and machine this leads you to microservices architecture.

What is microservices?
The meaning is derived from the term itself, it's a micro which is small units and services which implies a group of different small services, each service does a single function or a group of small functions which let this microservice work independently.

As the previous definition, we can rethink how can we make a reliable social media app like Facebook based on the microservices concept?

We can divide this application into small services to achieve the microservices concept, so we can make a service for chats and messages, service for profiles, service for pages, service for ads, service for AI and content suggestion and finally service for listing your feeds.

This is amazing, now you have different services and each service can work independently on a separate machine, a container with its own resources so the application now can be distributed over several machines and may over datacenters!
But there is a problem here, how can these services share and get the same data to be used in a different way in each service?
For Example, the feeds services need some information about you to know the type of feeds you would like to see, friends information to get their posts and list them to you and some other things the service might need to know, however, this data does not exist in this service so how can we do this task?

After achieving the first step which is distributing the application on multiple systems and machines to build microservices, you now need to distribute your database over multiple machines and systems, which will lead you to the next article :satisfied:
see you later :heart: