Tag Archives: Architecture

Microservices – A Primer

What is Microservices?

Wikipedia definition says

Microservices is a variant of the service-oriented architecture (SOA) architectural style that structures an application as a collection of loosely coupled services.

But there is no official definition of Microservices by industry standards. It’s recent phenomenon in software industry to architect the new softwares which should be light weight, easier to deploy and scale, easier to refactor individually and could work independently.

To understand in details, you can definitely read Martin Fowler’s Microservices or Chris Richardson’s Microservices.

We will not be covering this post in detail as compared to link I have posted here. Microservices are small services that can run independently, but can also easily communicate with other services.

Microservice Architecture vs Monolithic Architecture

In traditional monolithic architecture style, there is a single application with single code base. An application contains number of modules which are interrelated and can have external dependencies. It’s a multi-tier enterprise application and has been used to build software for long.

Microservice architecture style was born out of need to build an application that could easily be supported for mobile applications. Older style was not easy to support for mobile and new generation way to handling of data. Any large enterprise application can be easily built using microservices architecture style.

How to identify Microservice Architecture Pattern?

A simple ground rule of microservice architecture pattern is to build a standalone service that can be run without depending on any other service. That means for a large application can have more than one services talking to each other, communicating with their own databases, but still performing the business logic. Databases are used to ensure loose coupling of services.

A large enterprise e-commerce application can consist of following services

  1. Backend service REST API to manage data
    1. Account Service
    2. Shipment Service
    3. Inventory Service
  2. Runtime service to handle runtime and backend data to process business logic
  3. Logging service
  4. Error Handling service
  5. Session service

UI for the e-commerce application can be built independently to use backend services to show/edit data.

By standards, there are few rules to identify microservices patterns

  1. Decomposition by business capability
  2. Database per service pattern
  3. API gateway pattern
  4. Client-side discovery and Server-side discovery

Pros and Cons of Microservices

Pros

  1. Deployability – They can independently be deployed.
  2. Reliability – A fault in the service can only bring down that service, depending on handling in application, rest of the application can still be accessed.
  3. Scalability – Each microservice can be scaled depending on requirements using clusters and grids.
  4. Availability – Dispatching the patch or newer version of service requires less downtime compared to regular monolithic application.
  5. Management – Easier to manage
  6. Design and Development – Each service can be developed independently and helps developer to manage the service easily without worrying about other services.

Cons

  1. Performance – All services involved in application have to communicate with each other over network and that could hamper the performance.
  2. Testability – Automated tests are harder to manage and run.
  3. Memory usage – Possible duplicate data across services and lot of duplication in cache.

References

You can read more about Microservices at following links:

  1. Microservices by Chris Richardson
  2. Microservices by Martin Fowler
  3. Stackoverflow post about microservices
Advertisements