Microservices architecture part 1
I know that everyone knows what microservice is and how to apply it to a certain extent. Will go deep and get the full understanding . My goal is to see that you get the awareness of designing an architecture with microservers properly.
Fist will go for basic.
What is microservice architecture?
As the name implies microservice means your application will be divided into a set of small services. That means a microservices architecture is mainly oriented to the back-end, although the approach is also being used for the front end.
Microservices: a definition of this new architectural term
Martin Fowler: The term “Microservice Architecture” has sprung up over the last few years to describe a particular way of designing software applications as suites of independently deployable services. While there is no precise definition of this architectural style, there are certain common characteristics around organization around business capability, automated deployment, intelligence in the endpoints, and decentralised control of languages and data.
Source : https://martinfowler.com/articles/microservices.html
Before going to the microservice will get one step back and discuss monolithic architecture.
In a monolithic application, the majority of logic is deployed and runs in a centralised, single runtime environment or server. Monolithic applications are typically large and built by either a big team or multiple teams. This approach requires more effort by and orchestration between the teams for any change or deployment. Over time, better architectural patterns have been introduced to the monolithic model that help to add significant flexibility into the architecture. For example, one of the well-known patterns is model view controller (MVC),which decomposes the application into layers and reasonable components. Those patterns have several advantages, such as faster initial development, simpler application governing, and other advantages. The monolithic approach, though, has disadvantages, especially in the context of fast-paced technology changes in today’s environment.
What are the challenges with monolithic?
- Large code base
When new developers join your team, they have a lot of learning curves since they have a large code base. A large application code base might also overload the development environment tools and the runtime container used in developing the application. ( I know you(software company owner / architects / developers) have a lot of concerns about that :D) This, consequently, can cause developers to be less productive and might discourage attempts to make changes.
- Dependency on one technology stack
Day to day new technology will come to the world. Sometimes you want to replace your old technologies with new technology on some pieces. See the difficulty when you want to update all the code. new versions of the technology-stack development framework becomes difficult. As a result, you need to stick with old technology with your monolithic application or you(as a company) have to invest money to update fully.
- Deployment dependency
Since typical monolithic applications are all in one level(single runtime container) every single change you have to deploy fully. This will affect the continuous delivery also. As a result, you/your team will think about decreased deployment times and a slow response to changes needed.
- Scalability
This is one of the biggest challenges of a monolithic architecture.
You must run multiple instances of the application on multiple machines (with cloning the same application)in order to satisfy scalability and availability requirements. This way of scaling is inefficient and expensive.
here is the scalability cube….
The microservice architecture came to Address the above challenges.
Okay back to topic
Why microservice ?
- Many developers working on the same team
- productive continuous delivery
- application source code /logic need to easy to read and understanding
- add different different technologies for different parts on your application(frameworks, programming language)
- Better testability — services are smaller and faster to test
Microservices for different stakeholders
For the business owners
You want to promote your product to new customers.But it will take some time to make new changes because of using a large code base (as above) . Not only slow you will face so many dependencies.
When your product builds with microservice, it is built around flexibility and resiliency. resiliency is the main key for success in your business.
When we talk about resource allocation, you don’t want to hire developers with the same skill set since there are many frameworks/lang available in your product.
For the developers
If you are the new developer who recently joined, you have to get understanding the source code very quickly . The large code base is typically a headache for you. potentially increase your learning curve. I know when you read this you will remember what i meant :) . I am 100% sure it affected your mentality as well. When working on changes, the risk of breaking something else might cause the developer to hesitate with innovation and enhancing the application
So when it happens with micro service it will be easy since changes only affect small areas. No big dependencies. That will help increase productivity and innovation.
Drawbacks
Certainly, no technology is a silver bullet, and the microservice architecture has a number of significant drawbacks and issues.
- Developer need to attend additional complexity of creating a distributed system
- service discovery needed (will talk later)
- IDE/Tool not supporting for development
- Inter service communication needed
2. Deployment is not a easy task (span multiple services requires careful coordination)
Further, you have to address a few things. They are coming in the form of pattern
- how to partition the system into microservices
- How many micro services. What are those? It’s very much art. (PATTERNS FOR DECOMPOSING AN APPLICATION INTO SERVICES)
- How to communicate between services. (COMMUNICATION PATTERNS)
- Service discovery . check and logging.Exception tracking,Application metrics,Audit logging (OBSERVABILITY PATTERNS PROVIDE INSIGHT INTO APPLICATION BEHAVIOR)
- How to make services loosely coupled (DATA CONSISTENCY PATTERNS FOR IMPLEMENTING TRANSACTION MANAGEMENT)
- Evolution strategies
- When we come to different databases for different services, some queries need to be linked with another database table. But that’s not accessible . Its only access via api (PATTERNS FOR QUERYING DATA IN A MICROSERVICE ARCHITECTURE)
- Easy to do testing because micro service is really small. Since there are so many services , automated testing need to implemented (PATTERNS FOR THE AUTOMATED TESTING OF SERVICES)
- Security need to be implemented (SECURITY PATTERNS)
- Choosing the implementation stack (capable of supporting communication or messaging protocols)
Additional resources:
https://www.martinfowler.com/articles/microservices.html
Now you know what are microservices , pros and cons, what are the main areas you need to address. (What are the patterns)
Next few post will talk about more details about those patterns and how we build microservices with best.
Additionally will talk ..How weDesign a DDD-oriented microservice.
appreciate if you hit that 👏 button to help others find it.