Monolithic vs Microservice, What do you choose?
Tags: softwaredevelopment, architecture, devops
Published: 2021-01-23 05:59:03

I have already work software devlopment and my repository is Devops engineer. My company have devlopment process is agile, devops cuture and microservice for develop application in company.

I have a question that what do you choose monolithic or micro service for devlop software application.

Thank you for The book Microservice patterns
(https://www.amazon.com/Microservices-Patterns-examples-Chris-Richardson/dp/1617294543) 
In the chapter one in the book make good decision for my result and The have many recommendation about implement, testing and deployment for you start develop microservice application.


<h3>Monolithic Architecture</h3>
![Monolithic Architecture](https://dev-to-uploads.s3.amazonaws.com/i/wz1t2m7elb6gg6jy8732.png)
<center>picture from book Microservice pattern(page 3)</center><br/><br/ >



A monolithic architecture is the traditional unified model for the design of a software program and compose business logic application for the one source code and one service.
(https://whatis.techtarget.com/definition/monolithic-architecture)


<h4>Benefit of Monolithic Architecture</h4>
- <u>Simple to develop</u> IDEs and other developer tools are focused on building a single application.
- <u>Easy to make radical changes to the application</u> You can change the code and the database schema, build, and deploy.
- <u>Straightforward to test</u> The developers wrote unit test, end-to-end tests that launched the application in one source code.
- <u>Straightforward to deploy</u> have one source code for build and deploy result in easy to deploy (for small application I love it.)
- <u>Easy to scale</u> can ran multiple instances of the application behind a load balancer(application sohuld be stateless. about stateless/stateful -> https://www.redhat.com/en/topics/cloud-native-apps/stateful-vs-stateless)

<h4>Drawback of Monolithic Architecture</h4>
- <u>hard process develop for the big team</u> imagin you have 100 developers in project. you have 50 or more commit, merging or pull request every day. they make overhaed process for you.
- <u>slow deployment when big source code</u> very log for build, complie, deploy and testing.
- <u>hard for mange resource</u> some bussiness logic code use a lot of resource such as generate report feature. you can't separate resource becase all bussiness logic store in same place source code
- <u>effect of compiled code broken</u> some devloper make some broker code in source code result in all compiled code broken.
- <u>technology stack block</u> example  you have java application and have new feature. You try implement application with golang for new feature and golang application have performance and manage resource more than java application but you can't adapt to main application becase your main application is compiled with JAVA.

<h3>Productivity in Sofware Architecture</h3>


![Productivity in Sofware Architecture](https://martinfowler.com/bliki/images/microservice-verdict/productivity.png "Productivity in Sofware Architecture")

(https://martinfowler.com/bliki/MicroservicePremium.html)

In the picture you can see when you implement software with monolithic such as add feature or refactor code when source code is big you have a long time to compile unit test and build source code result in make one ploblem for slow producitvity but you implement software with microserivce same way like. The time conpile and build focus in new feature code or refactor code and not make effect of other service result and about git management you can separate source code and developer teams help you for reduce manage git such as many commit and pull request.

All about of deployment time and proess development result in microservice faster productivity than monolic when your application is growing fallow the picture. 

<h3>Microservice Architecture</h3>
![Microservice Architecture](https://dev-to-uploads.s3.amazonaws.com/i/gxh6unfnj4ctg5ug5xgq.png)
<center>picture from book Microservice pattern(page 13)</center>
<br/></br/>

Microservices is an architectural style that structures an application as a collection of services that are

- Highly maintainable and testable
- Loosely coupled
- Independently deployable
- Organized around business capabilities
- Owned by a small team

(https://microservices.io/)

<h4>Benefit of Micro Architecture</h4>
- <u>it enable the continuous delivery and deployment</u> enable for CI/CD tools for deployment
- <u>Service are small easily maintained</u> 
- <u>Service are independency deployable</u> about deployment you shouldn't recompile all service.
- <u>Service are independency scalable</u> when one service scale all service needn't scale. 
- <u>enable for separate team</u> you can separate big team to many small team for implement and manage each service. 
- <u>allow easy experimenting and adoption of new technologies</u> you can separate service and team for implementing new framwork or new programing language.
- <u>increase reliability</u> when some service is down but other service can still working.

<h4>Drawback of Micro Architecture</h4>
- <u>finding the right set of services is challenging</u>
- <u>increase complex</u> distributed systems are complex, which makes development, testing, and deployment difficult
- <u>increase networking traffic complex</u> deploying features that span multiple services requires careful coordination. 
- <u>adopt the microservice architecture is difficult</u> micro service help your solution for you have big source code and big team developer but about many process suach as testing process, reliable of build ACID transaction process, deployment process and orther are change from monolithic result in difficult for adopt.

<h3>Conclusion</h3>
When you have a small project, demo project and small team monolithic architecture is a good way to use in devlop your software architecture. when your project is growing, a lot of feature is coming or you'll have a big team. Microservice architect is one of good way solution to adopt your software architecture development but when your adaopt you have a new many process develop and maintain your application and The book Microservice patterns (https://www.amazon.com/Microservices-Patterns-examples-Chris-Richardson/dp/1617294543) is one of good resource for help you develop application with microservice.