Story of Microservices!
All you need in one Place!😉
What is Microservices?
As the name implies, a microservices architecture discusses breaking down your program into smaller, distributed services, each of which provides a certain tiny business or technical functionality. Depending on your IT infrastructure design, these services are then independently deployed on various containers (Docker, Vagrant, etc.) or physical/virtual machines. These distributed services (micro-services), however, should be stateless by nature in accordance with the microservices design so that they may be readily replicated and scaled up or down.
Services of Microservices
- Highly maintainable and testable
- Loosely coupled
- independently deployble
Each service in a microservices architecture is independent and only implements one capability.
What’re the top companies that use this Technology
Why we use Microservices?
Let’s take a look at the architecture that prevailed before microservices, which was monolithic architecture. In layman’s terms, it’s like a huge container containing all the software components for an application example.
What are the challenges faced in monolithic architecture?
- Inflexible — Monolithic applications cannot be built using different Technologies.
- Unreadable — When one feature of the system fails, the entire system fails.
- Unscalable — In order to scale applications, the entire system must be rebuilt each time the application needs to be updated.
- Blocks Continuous Deployment — It is not possible to build and deploy many features of the applications simultaneously.
- Slow Development — Since each feature has to be built one by one in monolithic applications, development takes a long time.
- Not fit for Complex Application-Complex applications have tightly coupled features.
☘️“Microservices evolved as a result of these challenges”☘️
Microservice Architecture
🗈 Each microservice has its own load balancer and execution environment to execute its functionalities, while also capturing data in its own database.
🗈 Using service discovery, microservices find out how they communicate and perform operational tasks such as monitoring, automation.
🗈 Using API Gateway, all functionality is performed by microservices and communicated to the client.
🗈 Since all internal points are connected to the API Gateway, anyone who connects to the API Gateway is automatically connected to the whole system.
Microservices Features
- Autonomy — Teams and developers can work independently, which speeds up the development process
- Decoupling — services with a system are largely decoupled. In this way, the application as a whole can be easily built, altered, and scaled.
- Componentization — It is easy to replace and upgrade microservices because they are treated as independent components.
- Capability — A microservice focuses on a single capability and is very simple
- Agility — With microservices, new features can be deployed quickly and discarded again. Because, of its support agile development.
- Responsibility — Instead of treating applications as projects, microservices treat them as products for which they are accountable
- Decentralized Governance — Developers are free to choose the best used full tools to solve the problem, so there is no standardized pattern or technology pattern.
Advantages & Disadvantages
Microservices Tools
Finding the right tools is the first step to developing microservices.Many of the best tools for developing and managing microservices are open source
- Docker — Docker is an open source project that allow us to create deploy and run application by using containers
- Kubernetes — kubernetes is a container orchestration system and handles the automation of scaling, deployment, and management
- Mesosphere — Mesosphere is a container platform and its a cluster manager, operating system and container platform built.
- OpenShift -Openshift is a container application platform, a supported application on kubernetes using Docker containers.
- Hystrix — Hystrix is a fault tolerance java library. This tool use for separate points of access to remote services, systems, and 3rd-party libraries in a distributed environment like Microservices.
Microservices Best Practices
Designing
Design should be a domain driven design. That means when you design a service or think to move to microservice you need to make sure you have a fresh domain driven design. In that case we don’t need to rewrite or re design the system. If anything not relevant to your system what you have to do is remove it and rebuild only the part.
HardCoded Values
Instead of hard-coding foreign services addresses, you should use a service discovery tool.
Logging
Developers struggle with logs because either have not logs and either have too much logs both are bad. because of sometimes same error log twice. Therefore develop to print the log in last layer of you application. So that you can log management frameworks like Splunk, Logstash ..etc
Versioning
Version upgrade is a next good practice because its better to upgrade to new version rather than closing existing one.
Latencies
If you’re each and every service is try to validate the user then it will add more and more latencies to your round trip. Think you use oAuth token to validate some of your program and it takes 20ms and if its come in 3 different services it takes 60 ms additionally to validate the token.So that what you can do is you can add separate identity validation service..
Tolerance
If you have multiple services that means you have possible to have multiple failures.That means of you have 3 of services and one is getting slow, Then their building a queue behind it. So that you have to have a strong fault tolerance mechanism.
Documentation
Every developer doesn't like to write documentation but it is must because there is no documentation means other party cant understand what you have done. Swagger would be alternative because you can write documents in technical way. Swagger is best too for it.