Monolithic Architecture

Before understanding the Microservices architecture, we need to understand what is the traditional approach and what are its problems.

In a client-server model, the server-side application follows monolithic architecture i.e. it is a single large unit that performs everything. It acts as a single unit that handles the HTTP requests, executes business logic, performs database operations, reads files etc.

monolithic architecture

Drawbacks of Monolithic Architecture

  1. A small change to a particular component of application may require building and deploying the whole application again.
  2. If a particular component fails, the whole application may go down.
  3. If we wish to scale some components, we may need to scale the whole application instead of just the components.
  4. Not easy to use multiple technologies and multiple programming languages for a single large project.

What is Microservices Architecture?

Microservices architecture breaks large software projects into loosely coupled components, which communicate with each other through simple APIs. Each component is responsible for handling its own defined tasks and to communicate with other components through simple and universally accessible APIs.

The most important thing to consider now days is SCALABILITY and one of the most frequent asked question is: Is your application scalable?

 

microservices

Advantages of Microservices Architecture

  1. We can choose any technology or programming language to build a particular component.
  2. Each service can be build and deployed independently.
  3. If we need to re-build a particular component, we don’t have to stop or deploy whole application, only that particular component needs to be fixed.
  4. Failure of single component will not crash the whole application.
  5. Scaling components will not disturb other components and application as a whole.
  6. It is easy to add more components and maintain them.
  7. We don’t have to depend on a particular technology stack.

Disadvantages of Microservices Architecture

It is not necessary that everything new is always good. We have to carefully decide before choosing a particular architecture. Here are some problems we can face with Microservices architecture:

  1. Managing a distributed system is always a bit complex. We have to take care of every request between modules and may need to write additional code to handle failure of components.
  2. The request between multiple independent components adds delay to final response.
  3. Testing a microservices based application may be difficult because of involvement of multiple technologies and programming languages.
  4. Deploying microservices may be complex and is not as straight forward as uploading your files to FTP server.

With the right kind of automation tools, above discussed disadvantages can be handled.

Finding Microservices

How does clients of microservices find the location of service instances?

Service Registry comes into the picture. It is a database of all microservices, their instances and locations. Service instances are registered when the Service Registry is started and de-registered when Service Registry shuts down.

For more information, you can have a look at Eureka and Apache Zookeeper