Microservices
are the software architectural style derived from various traditional
architectural styles and design principles like SOA, Single responsibility principle.
This is the more recent
term which promotes implementing applications as a set of simple, granular,
independently deployable services. It captures a number of best practices and
hypotheses about scalable software development practice of organizations like
Heroku, Netflix, or Amazon to name few.
How
Microservices are different from
traditional architecture style?
Let’s assume
we are developing an application .Fortunately we are lucky like Facebook or
Flipkart team and the application become huge success and grow more complex
over time. The complexity creates challenges in development and maintenance.
There are two essential strategies to manage the development problem: either our
team can keep everything together: a monolith system or team can divide a
project into smaller pieces: microservices.
The
traditional monolithic system approach generally have a single code base
containing all application logic, File and DB storages. All programmers
contribute to same code base. This approach is initially simpler and inter module
refactoring is easy as the application is altogether integrated. But in longer
run when we have to scale the application we have the option of replicating the
monolith on multiple servers. This sometimes causes wastage of resources
.Scaling requires scaling of entire system rather than the part that needs only
requisite resources. Complex black box intermediary between client and server
generally called Load balancers is needed. Changing the code is also sometimes
frustrating as the small changes in application required entire monolith to
rebuild, test and deploy.
The new
concept of development called microservices is not a completely new concept. It
is just a more robust and sometime complex form of previous known well
practices.
Fig:
Differentiate monolithic and microservices architecture
In short for
microservice base application:
Generally
the microservices are written in different language following different
frameworks. It helps in writing performance sensitive code in a lower level
language and other with modern language with high abstractions. Microservices are
independently scalable and deployable. Generally, Application are divided into microservices based
on business functionalities. We create the replica of at microservices level.
These services are developed and maintained by different teams and sometimes
different companies.
It enforce a
separation of responsibility in healthy ways, make it easier to onboard new
developers, enable you to choose different languages and technologies for
different microservices, and can help prevent a problem in one part of
your code from bringing down the whole system as each microservices are
independent entity.
Webservices
(Rest, Restful,SOA) and Microservices
SOA
SOA is an
architectural style with focuses on services. But what you may call services is
differs based on opinions and that is a whole different big topic.
Websevices :
Webservices
are the subset of SOA uses internet related technologies like HTTP, FTP with messaging
protocol like XML,SOAP.
RESTful:
RESTful is a
subset of Webservices that uses HTTP as communication protocol. There are
certain standard in development that relevance to creating URLs. Restful was
more restrict form of REST Implementation where a resource would have a unique
URI and it would be managed through CRUD operations mapped to HTTP verbs Create
= PUT, Read = GET, Update = POST, Delete = Delete.
The exact
difference between REST and RESTful is vague and a debatable topic.
Microservices:
This is a
recent terminology and a subset of SOA. It promotes implementing applications
as a set of simple independently deployable services in contrasts with SOA
where a set of complex services are needed to build complex system typically requires
intelligent enterprise bus for communication.
Advantages
of microservices:
·
Simple,
focuses on doing single things right.
·
Enable
to develop each service using the most suitable tool and technology.
·
Inherently
loosely coupled.
·
Enables
multiple development teams for continuous independent delivery, allowing frequent
release keeping the rest of system up and running.
Disadvantages
of microservices:
·
Brings
a lot of operation overhead like load balancers, messaging layers to glue the
services, insurances of all the services remain up, do not run out of disk
spaces or deadlock.
·
Needs
a very robust release and deployment automation.
·
Absence
of open source tools and framework to support microservices. It needs
significant investment in custom scripting to manage these services before
writing a line of code that delivers business value.
·
Collaborating
services needs to agree the contracts with both side needs to exchange the same
message format and understand the same semantic of messages. A change in the
syntax /semantics on one side causes this change to be understandable to all
other services. That sometimes causes changes in many services.
·
Microservices
implicitly implies distributed computing and Distributed computing is complex.
Conclusions:
Definitely we
should consider the microservice based architecture as a part of scaling the
project but at the same time we should consider challenges inherent in running
multiple services which implies multiple codebases. Each service causes
overhead, and though overhead can be reduced by an order of magnitude by
running in a PaaS environment, but still need to configure monitoring and
alerting and similar services for each microservice. Microservices also make
testing and releases easier for individual components, but incur a cost at the
system integration level. We need to plan for system behavior if one of the
services goes offline.
Overall,
though, a considered strategy of decomposing your application into smaller
pieces will allow you to make better technology choices, give your team more flexibility,
independence and can give you more ways to maintain availability with high
probability.
I am developing a demo app based on microservice and will post in next blog soon. Stay tuned!!