6,063 total views, 7 views today
So you want to build an agile, robust & scalable business app, and you keep hearing about “Microservices” or “Microservice architecture” for development. The below article will simplify the concept behind microservice architecture & why it is used during business app development.
The Previous Monolithic Approach
Before we dive down to microservices architecture development practice, we need to first understand the inconsistencies of the previous way of developing software systems. Earlier, a monolithic architectural style approach was used during development. Wherein, a single, autonomous unit is responsible for the entire functionality of the software.
In a client-server model, the monolith server-side application handles everything from authentication, HTTP requests & communication between browser/client, executing logic, database operations etc
Although the monolithic architectural style provides few benefits such as:-
- Easier to hook up components as they are placed in the same space
- Slight performance advantages as shared-memory access can be faster than inter-process communication
There are a vast number of drawbacks. For starters,
a simple modification made to a small section of the application, would require building & deploying a new version of the whole application.
Just the thought of doing that would make developers frown everywhere. But that’s not all,
- If you want to scale specific functions of an application post deployment, you may end up scaling the entire application itself instead of the required component
- Since even segregated components share the same memory, the ‘flexibility’ aspect during agile development process gets taken away
- Monolithic architectures can be hard to understand, due to underlying dependencies or side-effects. This can be difficult for someone to understand, who was not directly involved in the development
- Definitely not suitable for business apps
Microservices or the microservice architectural style is an art of creating applications as a set of services each part of a single process function all revolving around a central business process.
Each service is fine-grained, lightweight and loosely-coupled making it easier to develop, deploy and test.
In other words, all services are almost independent of each other but together form a complete application. Each independent service or application is capable of scaling independently and running in their own memory space.
Take an example of any modern e-commerce software that takes orders, verifies inventory & credit and ships the items. An application such as this would consist of multiple services, a store-front UI, backend services etc – Using microservices, the e-commerce software architecture would look something like this
3 Benefits to sum up the need for microservice architecture
1) Better Scalability
- Ease in scalability is one of the main advantages of microservice architectures and is why the style perfectly suits large projects like business apps
- Each module/service can scale independently from other modules. Taking the above depiction, if you needed to scale up the inventory service for your e-commerce application – You would just need to scale the appropriate API to handle the extra data.
- The ease of scalability removes any long-term commitment to a technology stack. Whether it’s integrating a new tech sack or rewriting an outdated one
- Using standard protocols, such as a REST-ful API, microservice interfaces can be used by other 3rd party services/applications without using shared libraries or language binding
2) Easier Testing & Fault Isolation
- Unlike monolithic-based applications, a memory leak or error in one service will not affect the other components of the overall application
- This makes it easier for testers to isolate bugs in the applications & faster for developers to rectify them
- Services are generally small, this makes it faster for testing
3) Easier Deployment & Integration
- Unlike monolithic applications, where a single code change requires the entire application deployment, in microservice architecture, the deployment is faster & easier
- This makes making improvements easier as the microservices are built around a single business process. Which makes it easier for programmers to improve on a particular service without affecting other services or the overall business logic.
- DevOps is now greatly organized as individual teams can be set up to handle integration & deployment of specific components/services of the application
- It is easier to recompose or reconfigure decoupled services to serve other purposes during development
- Easier to understand for new team members as they can quickly understand the development & working of individual services to the overall business logic
- One can use fully automated deployment tools using opensource integration tools to speed up the entire development process. This ensures that processes that would normally take months to deploy, can be done in a matter of weeks.
There are, however, few drawbacks to the microservices approach
Increased memory consumption
Microservice architecture replaces N monolithic application instances with N*M services instances. Which means, there is an increase in the overhead of M times, each time a JVM is called during service execution.
Careful coordination between teams
Although using microservice architecture can help organize your DevOps, careful coordination between each team is required when spanning multiple services.
Non-uniform design architecture
The freedom of mixing various technology stacks per service comes at the cost of loosing uniformity in your application’s architecture and design. This may lead to additional maintenance cost in the long run.
To sum up,
It is far easier to develop, test & deploy business apps that require scalability & agility using the microservice architectural style.
When building, you can combine the various benefits from ease of integration/testing/deployment with the asynchronous data handling provided by Rx programming and further improve scalability & deployment using Dockerized app container technology
One can bring a business app, from idea to deployment an extremely robust & scalable way. Not to mention, at a much faster pace than other present architectural styles such as monolithic & service-oriented-architecture(SOA).
Image Credits & Resources