What are microservices?

In this article, we are going to learn about software architecture and evaluate a bit about the popular model that is Microservice.

Software architecture is the organization of a system consisting of many components such as the web service, database, memory and layers thats implement communication. They are associated with each other or with a certain environment. The ultimate goal of system architecture is to solve a business problem.

At the present time, there are two patterns of software architecture that are being popularized:
- Monolithic architecture
- Microservice architecture

Monolithic architecture

Monolithic architecture

Monolithic is suitable for small-scale projects. In the application of the monolithic architecture, the benefits can be mentioned as below:
- Simple to develop: the development process is simple and direct, centralized management and basic development step will not be repeated. All development is on same project. Development flow is as simple as submitting changes, reviewing, merging code and continuing.
- Simple to deploy: Developer simple need to deploy the WAR file (or directory hierarchy) on the appropriate time.
- Simple to scale: Developer can scale the application by running multiple copies of the application behind a load balancer.

However, once the application becomes large and the team grows in size, the limitation that this model brings is quite large:
- Difficulty in maintenance: code coupling problems, blocks of code sticking together, new members will be difficult to understand and modify the application.
- The development process will lose flexibility: the time to build features will be long, block each other. Take a lot of time to rebuild the entire project when has any change, no matter how small.
- The stability is not hight: any single error can cause the entire application to crash.
- Scaling the application can be difficult: this model can't scale with an increasing data volume. Each copy of application instance will access all of the data, which make caching less effective and increases memory consumption and I/O traffic. Also, different components have different resource requirement - one might be CPU intensive while another might memory intensive.  
- Difficult to innovate: the monolithic applications forces you to married to the technology stack you choice at the start of development, so can be difficult to incrementally adopt a new technology.

The upper-limited properties of the monolithic architecture led to the development of the microservice architecture.

Microservice architecture

Microservice architecture

Microservice architecture refer to the relatively small, independent development process that divides the system into services. Each service has its own logic, responsibility and can be deployed separately. This architecture also refer to trend of separating the architecture into loosely coupled, collaborating services.

Microservice advantages

Microservice provide loose coupling and separate context for each service. Each service will be broken down to focus on a specific business function or business requirement. Each service has its own storage and can has its own database. Enables the continuous delivery and deployment of large, complex applications.
- Each service is small and so is easier for developer to understand and modify.
- Faster to test and deployed independently by a small team of maybe 2 to 5 developers. Easier for deployment configuration. Easier for scaling service.
- The developer will easily focus on work and improve performance. The application starts faster, easier for 3rd party integration.

Improved fault isolation. If there is a failure in a service, only that service will be affected. The other services will continue to handle requests.

When developing a new service you can pick a new technology stack. Similarly, you can rewrite the existing service using a new technology stack when making a major changes.

Microservice disadvantages

Distributed systems are complex and difficult to manage.
- Developer must implement the inter-service communication mechanism and deal with partial failure.
- Implementing requests that span multiple services is more difficult and requires careful coordination between the teams.
- Testing the interaction between services is more difficult.

The operational complexity of deploying a system comprised of many different services.

The increased memory consumption.

And one more thing is developers need to know DevOps.

Thank you for reading and enjoy.

References