What is a microservice? Why we need it?


Before we touch upon microservices, let us discuss why are they needed? Why now? Why not 5 years ago or 5 years down the line?

We started programming world with procedural programming in languages such as C, Pascal etc., we invented new way of doing same using Object Oriented principles where we talked about the Object Orientation, encapsulation, abstraction etc. (C++, Smalltalk etc.).

Initially, we were running all our classes, interfaces on same machine with just logical separation of functional layers such as Presentation, business and data access layer followed by actual database management system. We found the need of having more componentization to run components separate so they can scale individually, we adopted COM (Component Object model) and DCOM (Distributed Component object model). Finally, we reached more mature and web enabled option of Services and modernized our applications using Service oriented architecture (SOA) and principles.

Now to understand what has gone wrong in so far programming and deployment models? – Well, there is nothing wrong in what we did so far, but there is scope for improvement as we witness technological innovations around us which are primarily business driven.

The problem with our recent adoption of SOA based applications or traditional client server systems is – we have applications which are logically divided in different logical layers (same machine) or sometimes different tiers (different machines) and the focus has been the functional nature of these layers like presentation/ web, business and data access – but it was never the business requirement which insisted us for this separation.

Because of just functional separation, applications became monolithic from business point of view – as I can’t deal with specific set of business requirements independently without disturbing other requirements, maintenance becomes difficult too. I can’t scale business scenarios separately or make more resilient, also the testing and deployment becomes more complicated since you are always dealing with one functional layer or application as a whole, instead of set of business scenarios. This leads to more time to deliver few changes to business and get the feedback, more time to test to understand impact and dependency, since everybody is testing the same application, you need to wait for others to test and confirm before you deploy, though, one part of it may be ready to go.

Also Monolithic applications can be scaled by just cloning it on more than one server, this way of resource utilization is not efficient as it does not have possibility to provision more resources to specific business requirements than other least used features, this causes in-efficient use of resources causing more cost of ownership. With Microservices adoption, resource utilization can be optimized.

So why is this new paradigm coming our way now not earlier? – I would say there are two reasons to it 1. Increased adoption of agile delivery model 2. As Cloud becomes reality and the way to go

Agile delivery model is most widely used and becoming more and more popular because of its ability to deliver fast, helping business achieve more aggressively – what else do you want?

As we helped business to go to market faster, test and provide feedback so improvements can be done, that raised organizational expectations on further engineering the way we write our applications and how our applications can be deployed to sustain un-predicable business growth.

So, in a nutshell, if I can use agile methodology (preferable but not limited to) to develop, test and deploy specific business requirement independently without tight coupling with other requirements or components, I can write microservices for that. Additionally pre-requisites are – Microservices should be resilient and scalable independently for un-predictable user growth, and for high resiliency you need Microservices to report health continuously so corrective actions can be taken.

As result of this, your application will become collection of Microservices (each addressing one unique business requirement) which can uniquely identify each other, communicate with each other, however, still remain independent as far as their versioning, scaling and internal business data and changes are concerned.

Cloud computing platforms such as Windows Azure helps implement all above tenets of microservices providing adequate resources and models for high resiliency, scalability and cost efficiency.

So if we have to conclude with top 3 rewards of using Microservices, these could be –

  1. Faster Delivery time due to focus on business requirements, respond to your customer faster
  2. Scalability which provides agility to your business, allow your business to venture into new geography without any wait – adopt more customers, support inorganic growth
  3. Improved resource utilization to reduce cost of ownership

In my next article, we will discuss more details on microservices.