Web Applications to Microservices 📳(MICROSERVICES — Part-1)

Irushinie Muthunayake
Geek Culture
Published in
8 min readJun 6, 2021

--

An Overview of Microservice Architecture

Monolithic Architecture

What we have today is called Monolithic Applications. These are built as a single, unified unit, or in other terms, we can say that the monolithic applications have a single executable file for your entire application (The entire application is packed into one file).

Let’s discuss some advantages and disadvantages of Monolithic Architecture.

Advantages of Monolithic Architecture

Easy to test — As it is a single application, testing the entire application is easy.

Easy to monitor — The developer knows the place of every part of the application as it is a single application. Therefore monitoring is easy.

It is easy to start a new application and to develop it when using the monolithic architecture. Also, it is easy to deploy as all the actions that are needed can be carried out in one directory at once.

Has a simple infrastructure.

Disadvantages of Monolithic Architecture

If you need to make a small change in one process of the application, but according to this architecture, you need to send the entire file.

Think of the below scenario:

Assume there is a “Rent a car application”, there we have a user interface, business player, car registering process, customer registering process, renting process .. etc. So according to the Monolithic architecture, all these processes are put together and carry as one file. So now we need to send the entire file if someone needs to make a change in the User interface.

Accordingly, you need to test the entire application, you need to check the performance of the entire application.. etc.

② As it maintains a large codebase, it is significantly harder to understand.

Think of the below scenario:

Sometimes there maybe 100 or 1000 engineers who will develop the same single application. So if some issue arises, developers must have to go through a separate support process and the debug process will be really hard. The deployment process is also hard as it needs to make sure that everything is smoothly transferred to the new version.

③ Sometimes doing updates for the applications can also be a challenge for the developers as it redeployment of the system

④ As most of the elements are dependent and related to others, Therefore, it is really hard to change the application to a new language, framework…etc.

Service-Oriented Architecture (SOA)

This is an architectural design that we can see in computer software design. Here the components of the application provide services to other components over a network or through a communication protocol. Service-Oriented Architecture makes it easy for software components to work with each other over various networks. The main concept of the service orientation is independent of any vendor, technology, or product. Some people say that the microservice is SOA 2.0. SOA can be categorized into 2 parts as below:

Functional aspects

Quality of service aspects

Advantages of Service-oriented architecture

✹ Easy to maintain

✹ Scalable

✹ Reliable

✹ Platform independence

Disadvantages of Service-oriented architecture

✹ High cost

✹ High bandwidth server

✹ Extra overload

Microservice Architecture

Microservices can be defined as a path of cutting a large software application into loosely coupled units, which communicate with each other through APIs Also it is a possible option to solve all issues and traffic jams caused by the restrictions of the monolithic architecture. And this architecture follows the SOA -service-oriented architecture design. Some people say that the microservice is SOA 2.0.

Martin Fowler

Martin Fowler listed the below nine common characteristics of microservice architecture:

1. Design for failure

2. Organized around Business Capabilities

3. Smart endpoints & dumb pipes

4. Products not Projects

5. Decentralized Data Management

6. Infrastructure Automation

7. Decentralized Governance

8. Evolutionary Design

9. Componentization via Services

Features of Microservices:

📍 Microservice is a domain-driven development. It has to have a well-defined scope.

📍 It has the ability to run its own process and it doesn't depend on someone else.

📍 Microservices can communicate with some lightweight mechanism. Most of the time it is HTTP, but it is not just limited to HTTP. (Communicate with other services via lightweight way )

📍 Microservice should be able to scale and deploy as individual services. And it should be able to implement using different types of programming languages.

📍 When using microservices, we should maintain decentralized control as much as possible.

📍 And should develop this using a small developing team.

So finally Microservice can be defined as:

A method where a single application is developed as a set of small services, each service has the ability to run its own process without depending on others and uses a lightweight mechanism for communication. And these services share the least centralized management. Those services can be developed in different types of programming languages ​​and use different technologies for data storage.

Scale Independently

This was described perfectly in the book “The art of scalability,” which was written by Martin Abbott and Michael Fisher (2015)

🢃🢃🢃🢃

Ref:https://dzone.com/articles/scaling-microservices-advanced-approaches-with-the

Accordingly, this cube defines three different paths to scale an application. There are 3 axises as X, Y, and Z.

Horizontal Duplication — X-Axis

The application should be able to scale out through the x-axis. If one instance is not enough, that means It should be able to scale other instances and keep going.

Lookup-Oriented Split — Z-Axis

Through the z-axis, it should be able to sharding. (Maybe it should be able to geographically splits out the traffic)

Functional or Service Splits — Y-Axis

Through the y-axis, it should be able to functional decomposition. Accordingly, in the y axis, scaling decomposes a large monolithic application into tiny services. (here microservices come and fit)

If we take functional decomposition, many people tend to think that as the system is huge, they can't even think of microservices. Let’s understand it by the below example.

Example:

Consider we have a single application to register vehicles, register customers, rent vehicles, billing, and support in a “Rent a car application”. So according to the functional decomposition, now we can split out these 5 different services. Now assume that there’s another function called “Search function” and this is the most demanding service in the holiday season. So now we can scale the new search service to balance the load. But there’s no need to scale three different vehicle register services. Because that’s not demanding service at the moment.

How to develop a microservice application 🧐

📍 Language- We can select any programming language as each of the services can use different languages. Also, we can mix many types of languages, data-storage technologies, and development frameworks.

📍 Design- Should considers the domain-driven design. (Make sure that each service are not dependent on other factors)

📍 When considering the monolithic architecture, a single bug may lead to bringing down the whole system. And this can be overcome in a microservice architecture as it has independent units, that may not affect the whole application. But it doesn’t say that a microservice has the ability to resilient to failures. Transforming from a monolithic architecture to microservices will not automatically solve the problems So do not design your application by assuming that it will work smoothly without any doubts.

Assume that you have a service and you going to invoke service B. And suddenly service B is down and not working. Therefore now you should make sure that the whole chain of microservices does not unsuccessful/fail with the failure of this single service.

Hence you must implement Service resilient and fault-tolerant features.

📍 As there are so many frameworks to support microservices development. There are also some frameworks available for deployment as well.

📍 Avoid hardcoding the values.

Example: If you hard-coded another service’s name and if IP address or other service is changed in that service. And this may lead to a failure in the system. So to avoid that, we can use API gateways, governance registers.. etc.

📍 Need to restructure your developing team as you should have a full flex team(full stack) that has everything. This is because you need to distribute responsibilities among the team members.

Advantages of Microservices

✹ We can select any language as each of the services can use different kinds of languages.

✹ Services are scalable, so the programmers can scale different units of the system independently.

✹ It is easy to understand and diagnose any production issue as the team members are always aware of the entire service.

✹ Easiness of understanding is another advantage of this microservice architecture. With the enhancement of simplicity, programmers get the ability to understand the functionality of a service.

Disadvantages of Microservices

✹ Hard to monitor — As there are multiple applications.

✹ Testing is not easy

✹ Should pay much attention to versioning and deployment. Because if you ever change your version, the dependent services or other consumers who consume your service may get issues.

✹ Have to make sure that all the services are running perfectly to get the full application to work properly.

✹ Communication between services of microservice architecture is somewhat complex as it contains everything as independent services. So requests traveling between your modules should be handled carefully.

✹ Debugging issues can be difficult. (as each of the services has its own set of logs to go through)

Microservices in Java

Java can be recognized as one of the best programming languages to develop microservices. Below are some microservice frameworks that are available for java.

  • Dropwizard
  • Spark framework
  • Swagger
  • JHipster
  • Spring framework
  • Play framework

--

--