Micro Services – Brain Mentors Skip to content

Micro Services

What, how and why of microservices?

So, before understanding microservices we should be aware of the fact that these are also a type of web services.

What are web services?

  • , Web Service is an interface which expose a service on HTTP/ HTTPS/SOAP protocol for communication, exchanging data b/w different technologies.

Let’s understand this concept using trivago.

  • So here trivago is very known hotel booking sites.

    You need to enter the hotel name or the place where you want to have a booking, enter the check in and out time etc and click search.

    On that search button clicked you are shown with multiple options available for your search.

  • So what happens internally, where does trivago gets its data from?

    Actually trivago collects its data from several places like Airbnb, oyo, etc.

    Now trivago collects all the data using the provided web services and fetch the result in different formats.

    Key benefits of web services

    • Available over the Internet/ Intranet
    • Language interoperability
    • Exchange Data using JSON/XML/PlainText etc.

     

    Basically there are two types of web services:

    • SOAP
    • RESTFUL

    So now web services can be created using any of these two given approaches

SOAP webservices

  • Stands for simple object access protocol.

    SOAP is an XML based message protocol.

    Here comes the concept of WSDL (web service description language).

    WSDL is used for communication between consumer and provider.

    Here remote procedure call is used for invoking services.

    So a request wrapped in a soap envelope is sent over internet and reaches the responser.

    There it checks the WSDL where all information is maintained about the processing of the request.

    Once done the server again send the response back to the requester wrapped in an envelope.

Rest

  • It can use XML or json to send the data.

    Services are called very simply using just the url path.

    Rest does not uses too many standards for implementing any web services.

Soap vs Rest

What are Microservices?

Here many services come together to implement a single web application.

It is an architecture style.

Microservices also consists of web services.

According to the Netflix Architect “Adrian Cockcroft”

“Loosely Coupled service oriented architecture with bounded context”.

So each microservice will be having its own separate db, logics and everything with autonomous control over it.

 

Monolithic application architecture

  • Traditional Style
  • Big Container , contains entire app
  • It means all the features of application placed on one place.
  • g user profile, login, register, password reset, order booking , cancel, delivery  all of them are on one server.

So in monolithic architecture design we keep all the logic, database at a single place, which in turn will provide a single entry point for all the incoming requests.

Suppose if the requests increases, there is only a single point of failure.

If server crashes it’s a complete shutdown for our application.

This is the biggest advantage with the microservices architecture, here if there is too much load on a single server and somehow it stops, it is not going to affect other microservices they will keep on serving the incoming requests.

Also these small server can be scaled up on the basis of which server is getting more requests rather than scaling up the whole server even if it’s a single web service which is having more load, hence microservices are cost effective also.

Also while implementing these microservices we are concentrating on single sub system hence implementation is very precise.

Different microservices can be implemented in different underlying code base, so dependence on a single technology decreases.

Disadvantages of microservices

Managing a distributed system is harder.

End to end testing could be a little difficult.

Small projects would suffer more than gaining from implementing the microservices.

If data transfer is not managed properly among microservices there is a chance of hampered security.

Some requests may require more time as services are not at a single place.

Separate databases for each microservices.

 

Microservices can use two approaches for intercommunication among themselves:

  • Sync – Services talk to each other using direct request.
  • Async – Services talk to each other using Event Bus.

Pros:

  • Easy To Understand
  • No Special DB for Composite Operations

 

Cons:

  • Dependency b/w Services.
  • If any service fails, fail entire flow.
  • Response time is High, hitting many services behind the scene.
  • Can have Nested N – Requests.

Pros:

  • Response time is Low, Async way of hitting the Services.
  • No Special DB for Composite Operations

 

Cons:

  • Not Easy to Understand
  • Dependency b/w Services.
  • If any service fails, fail entire flow.
  • Can have Nested N – Requests.

Companies WORKING ON micro service architecture

  • Netflix
  • Ebay
  • Amazon
  • Uber
  • Spotify

 

Sign Up and Start Learning