Nov 22, 2016

Beginners Guide to Microservices - Part 1

Today, orgnaization and developers are constantly working towards making applications that scale or are distributed. This constant effort has evolved some very interesting architecture patterns and [Microservices](https://en.wikipedia.org/wiki/Microservices) is one of them. Microservice consists of independent deployable services.

This article focusses on :
    - The Basics.
    - What are micorservices ?
    - Different patterns of microservices. (Part 2)
    - Deployment strategies. (Part 3)
    
    
A bit about terminology used in the article:

    - What is a service ?
    Services in a microservice architecture are processes that communicate with each other over a network in order to fulfill a goal.
    - What is a component ?
    An individual software component is a software package, a web service, a web resource, or a module that encapsulates a set of related functions (or data).
    - What is a container ?
    Docker containers wrap a piece of software in a complete filesystem that contains everything needed to run: code, runtime, system tools, system libraries – anything that can be installed on a server. This guarantees that the software will always run the same, regardless of its environment.
   - Monolithic Application : Any application that is build as a single unit and is also deployed as a single unit i.e if at any point of time a feature is added or bug is fixed then the new version of the application is deployed. Even in load balanced environment the server/vm running application has the full copy of latest code or repo. 

What are Microservices :

Microservices is a terminology for a set of guidelines or architectural pattern which says that each service can be an independent process or constitutes a group of processes. These services are fully independent in terms of development and deployment. Microservices pattern also expects the deployment process to be fully automated. Les illustrate this more with the help of an example :

Developer A is working upon a feature that allows authenticated users to write comments on posts. 
Developer B is working upon a feature that allows authenticated to users write posts.

Monolithic Approach is that both developers are working upon same code repository and pushing their code as per the requirements, features are tested with each deployment and at times regression/sanity testing is also done. With every deployment a new version of code is deployed on server/s and application is again tested just to make sure things are working as expected. A bug in any of the developers code causes the entire application to break apart. This is what stakeholders or users want to experience.

Microservices Approach treats both comments and posts feature as separate services. Both services can share the same database or can have separate database (this will involve a bit of complexity at application level). Each feature works an an independent service without any dependency on each others code. This decoupling helps in deploying each service separately on different virtual instances or containers and in case one of the  service is unavailable, the failure can be handled gracefully and user can still explore other features of web application. 

In this post we have just touched the concept of microservices. I will continue to elaborate this post and wait for my next part in the series.




 References :


  •  http://martinfowler.com/articles/microservices.html#MicroservicesAndSoa
  •  http://microservices.io/index.html