Microservices - What you Need To Know

Microservices - What you Need To Know

What Are Microservices?

Microservices are defined as autonomous, independently deployable services that collaborate to form an application - Mark Heath i.e. (service A, service B, service c to form application ABC).

Microservices are a better approach to software development architecture than the initial monoliths technology, which encourages single processes, single hosts, and consistent technologies.

Note - Monoliths has their own advantages, as they are well suited for small applications

Pro & Cons of MicroService

Pros

  • Easy adoption by team members, i.e. (Microservices are easier to understand and rewrite )

  • Adoption of new technologies is faster

  • Easier reusability

  • Less downtime and risks as you deploy only the services that the changes are made

  • Cost-effective

Cons

  • Deployments are strictly advised to be automated

  • Monitoring needs to be centralized, i.e. logs and problems monitoring

  • Avoiding complex interactions between your microservices (inefficient chatty communications)

Evolving Towards Microservices

If you have an existing monolith, you can either

  • Augment a monolith i.e. Add new microservices for new adoptions

  • Decompose a monolith i.e. Identify and extract microservices from your monolith application

Note - It is advisable not to start your new projects as microservices as it is difficult to get the boundaries right

Microservices Contracts

Microservices are independently deployable, this simply means that we can upgrade a simple microservice without having to upgrade the clients of that service.

Avoid making breaking changes to the public interface (Contracts) of a microservice, this can be achieved by

  • Making new endpoints
  • Making new properties on the DTO's
  • Versioning your API's, where older versions must still be supported

Microservices Hosting Options

Virtual Machines

This approach can be quite messy (i.e. all microservices deployed on one virtual machine) or expensive (I.e. one microservice per virtual machine)

Platform As a Service

Examples are serverless platforms like AWS, Microsoft Azure e.t.c

They offer

  • Automatic Scale-out
  • DNS Addresses
  • Load Balancing
  • Security
  • Monitoring e.t.c

Containers

This allows you to package up all the microservices with all of their dependencies in such a way that they can run on any container host, it could be on the cloud or locally.

Examples are docker, Kubernetes

Microservices Communication

Avoid direct calls between your microservices and front-end applications to avert

  • Tangled dependencies which could cause cascading failures
  • Poor performance, if making a call to one microservice would require a call to multiple microservices.

A better approach is

  • Allow your microservices to publish messages through an event-bus and also subscribe to messages on that bus.
  • Using API gateway pattern, where the client application does not need to know how to connect to our different microservices. Here all the calls from the client application go through the API gateway and are routed to the correct microservice. This helps with.
  1. Easier security implementation

  2. Decoupling client applications from the specifics of our APIs

Example backend for front end API gateway.

Overall, microservices give you several options where you are free and flexible enough to leverage new technologies.

New tools and approaches being introduced to make the use of microservices easier, so keep learning and provide your insights on the use of microservices.

Thanks for reading, like, and share