Implementing a microservices strategy necessitates adhering to the notion of single responsibility. By restricting the scope of responsibility for a particular service, we can mitigate the negative consequences of that service’s failure. An outage or loss of a single microservice can have an enormous impact on the entire network.
A microservice should be precisely that: a microservice. Keep your microservices‘ app domains short and focused on a single logical functionality. This minimizes the effect of any faults that may develop with a particular microservice. Additionally, more minor services require less maintenance. As a consequence, updating and development are simplified.
In practice, how does this look? For example, suppose the microservice is an API client that takes requests to get data and requires an authorization token. An authorization token is required for all of these services except for this one. Why not simply incorporate authentication and token generation within the microservice itself? At first look, the benefit appears to be that there are fewer moving parts and hence fewer components to handle.
Eventually, additional services will require an authorization token as well. Your original microservice will quickly become an API server and an authentication system. If your API server fails, your authentication server will also fail. Likewise, any other application that requires an authorization token performs the same thing.