5 important aspects/components of microservices architecture
1. Microservices - Services that are built small enough so that their entire lifecycle can be owned and managed by a small team.
2. Service Discovery - A mechanism of how microservices can locate each other over network.
Example : if Microservice A wants to call microservice B:
It will use service discovery mechanism to fetch IP address and port of B and then call B.
Implementations : ZooKeeper, Consul, etcd, Eureka
3. External configuration - Enable services to run on various environments without a code modification inside the service.
Enable different configuration values for those services for different environments.
Dynamically change configurations without changing application code or restart/redeploy application.
Example - DB credentials and other details, application properties, environment variables for Dev, QA and Prod env.
Implementations : Consul, Spring cloud (enables various datastores to store needed configs)
4. API gateway - Provide a way for clients to access microservices.
May provide security, Load balancing , rate limiting etc.
Example - Enables clients to retrieve data from multiple services with a single round-trip call to API gateway.
Implementations : NGINX, AWS API gateway
5. Circuit breaker - Protect cascading failures of services, when just a few services are affected.
Example - If service A calls B, but response from B is very slow. This will quickly result in calls from A to B getting piled up.
Thus threads of A will be blocked causing issues to service A due to issue in B.
For this, A should call B using a circuit breaker.
Circuit breaker will fail the slow requests and prevent A from calling B for certain time thus protecting A.
Implementations : Hystrix, Resilience4j
What other microservices patterns and implementations have you worked on ?
Comments
Post a Comment
Have some feedback, comment or question ?
Post it here in comments section.