Engineering

A comprehensive guide to Microservices

Mastering design, development, and deployment of Microservices Architecture

Meenakshi Pal
Building Fynd
Published in
8 min readJun 23, 2023

--

An Introduction to Microservices

Microservices have emerged as a popular architectural style for building complex and scalable applications.

The fundamental principle behind microservices is the separation of concerns, where each service focuses on performing a single task or function. This promotes modularity, flexibility, and scalability, as different services can be developed, deployed, and updated independently without affecting the entire application.

Microservices have become a popular architectural style for building scalable applications. Let’s explore some real-world examples:

  • E-commerce Platform: An e-commerce platform can use microservices for managing product catalogues, customer accounts, and payments.
  • Travel Booking System: A travel booking system can utilize microservices for flight booking, hotel reservations, car rentals, and itinerary generation.
  • Social Media Platform: A social media platform can leverage microservices for user registration, profiles, content posting, notifications, and messaging.
  • Banking System: Microservices enhance the agility and scalability of banking systems, handling account management, transactions, fraud detection, and customer support.
  • Media Streaming Platform: Microservices power media streaming platforms with services for authentication, content management, recommendations, search, and transcoding.

Microservices enable scalability, modularity, and independent development, allowing applications to adapt to changing business requirements.

The concept of going Micro

In the world of software development, Microservices are a new trend. According to a survey conducted by O’Reilly in 2020, 86% of respondents reported using or investigating microservices as part of their software architecture.

In 2009, Netflix faced infrastructure challenges as its video streaming services grew rapidly. To address this, the company migrated from private data centres to a public cloud and adopted a microservices architecture. At the time, microservices were relatively unknown. However, Netflix became a pioneering example of a successful migration to a cloud-based microservices architecture. By embracing DevOps principles, Netflix revamped its infrastructure and won the 2015 JAX Special Jury award for its innovative approach. Today, Netflix boasts over a thousand microservices that handle various parts of its platform. Many top techs have also made the transition, like Amazon, Spotify, Uber, and many more.

The use of microservices is to deploy and create complex and large applications. In this special pattern, Service-oriented Architecture (SOA), all the smallest granularity process communicates to implement a big service or system. Microservices Tutorial is best for beginners as it helps them to understand the basic knowledge of Microservices Architecture.

The basic functions of Microservices Architecture are discussed in this tutorial. For easy understanding, basic and relevant examples are being used. Going step by step, we’ll begin with the basics and reach concepts which will help microservices professionals become more aware and efficient. Here is the Microservices Tutorial given below:

What is Microservices Architecture?

There’s no particular definition for the word microservices. The simplest way to define Microservices Architecture is a style of structure of application services. These can be maintained, deployed, and developed independently.

Microarchitecture System 1

Team #1 Microservices #1
Team #2 Microservices #2
Team #3 Microservices #3
Team #4 Microservices #4
Team #5 Microservices #5
Team #6 Microservices #6

In this system, you can see that each of the Microservices has its team working on it. This is what we called a Microarchitecture system.

Microarchitecture System 2

Team #1a Microservices #1a
Team #1b Microservices #1b
Team #2 Microservices #2
Team #3 Microservices #3
Team #4 Microservices #4
Therefore, the team working consequently in one microservices. Then there’s a chance to scale up faster.

In this way, we can speed up the work as compared to the monolithic application. Hence, we can see, there are many benefits of using microservices. Still, some companies are in the controversy of whether to use or not to use or switch from monolithic to microservices architecture.

How do Microservices communicate with each other?

Microservices communicate with each other using various protocols and mechanisms. Here are some common ways microservices can communicate:

  • RESTful APIs: Microservices often expose their functionality through RESTful APIs (Representational State Transfer). Each microservice exposes a set of well-defined endpoints (URLs) that other microservices can use to interact with it. Communication happens over HTTP, and data is typically exchanged in JSON or XML format.
To and fro function of restful API
  • Messaging Systems: Microservices can use messaging systems like RabbitMQ, Apache Kafka, or ActiveMQ to exchange messages asynchronously. Instead of direct communication, microservices publish messages to specific topics or queues, and other microservices can subscribe to these topics or queues to receive and process the messages.
  • RPC (Remote Procedure Call): Microservices can use RPC frameworks like gRPC (Google Remote Procedure Call) or Apache Thrift. RPC allows microservices to invoke methods or functions in other microservices as if they were local method calls.
A structured way of communication

It abstracts the underlying network communication and provides a more structured way of communication.

How are Microservices scaled?

Microservices can be scaled horizontally and vertically to handle increased loads and ensure high availability. Here are two common approaches to scaling microservices:

  • Horizontal Scaling: Horizontal scaling involves adding more instances of a microservice to distribute the load across multiple nodes. This approach improves performance and increases the system’s capacity to handle more requests. It typically involves using load balancers to distribute incoming requests across multiple instances of a microservice. Each instance of the microservice can run on a separate server, container, or virtual machine.
  • Vertical Scaling: Vertical scaling involves increasing the resources (CPU, memory, disk space) of a single instance of a microservice. It is achieved by upgrading the hardware or infrastructure on which the microservice is running. Vertical scaling is suitable when a microservice requires more resources to handle increased demand.

Service registry in Microservices

A service registry in microservices is a centralized component that allows microservices to register themselves and discover other services within the system.

  • It provides a directory where microservices can publish their network location and metadata. Other microservices can query the registry to discover available services and obtain the necessary information to establish communication.
  • The service registry handles dynamic updates as microservices come online or go offline. It may integrate with load balancers for even request distribution and offer health monitoring to detect and remove unhealthy instances. Overall, the service registry facilitates service discovery, load balancing, and dynamic updates in a microservices architecture.

Comparison between Monolithic and Microservices

Distinguishing characteristics between Monolithic and Microservices Architecture

Monolithic Architecture

It is the traditional way to build and deploy applications. The concept behind this is an indivisible unit that includes the server and client side, along with the database. In a single codebase, all the aspects are united and managed. Therefore, to alter the whole stack, together, the codebase must be updated. Being monolithic, it becomes quite complex. Hence, the overall development is quite long too.

Microservices Architecture

On the contrary, microservices architecture believes in being independent by breaking down the units, so that it can function on separate services. Therefore, it means, every service works on its codebase and logic. They use Application Programming Interfaces (APIs) for communicating with each other.

When to use which architecture?

Different instances have different requirements for Monolithic Architecture and Microservices Architecture. Let’s learn more about both scenarios.

When to plump for Monolithic Architecture?

If you are dealing with a small team, then Monolithic Architecture is best for you. Because in microservices architecture you have to deal with deploying complexity. Monolithic Architecture is also preferred if you are planning for a quicker launch, as it needs less time while launching. But in the future, it will need more time while updating your system.

Here’s a quick video link to briefly explain the microservices concepts- http://surl.li/htrmq

When to plump for Microservices Architecture?

If you are planning for a scalable web application, then Microservices are for you. Hence, it is going to be easier, as, new modules and capabilities can be added. If you are or plan to be a larger company, then you should opt for Microservices Architecture. As it will be easier for you to customize it later.

Advantages and disadvantages of Microservices

You can find numerous reasons for why opting for Microservices Architecture for your company. Let’s discuss the advantages and disadvantages of it below:

Advantages of Microservices:

  1. Improves productivity and scalability: If you are looking for a long-term project, then you have to work together on complex projects. With the help of microservices, you can divide your projects into small and independent units. This means the team on one’s own can act on the domain logic. It too helps in minimizing the effort and coordination. They can also make their own decisions based on technologies depending on their requirement.
  2. Integration with legacy system: It’s a bit hard to maintain monolithic systems. As it is believed that, many of the legacy systems are dependent too much on outdated technologies, even some systems are poorly tested and poorly structured. But fortunately, microservices are built to work with legacy systems. Hence, it got easier to improve the code and also can replace the system’s old parts.

Disadvantages of Microservices:

  1. Testing should be always independent: If you are testing all the microservices together, the test stage can be blocked by one microservice. Hence, the other microservices can be deployed. As you have to face more interfaces test, so go for independent testing of both the interfaces’ sides.
  2. Multiple Microservices are difficult to change: If any of the changes affect the microservices then it’s too difficult to implement. Therefore, if there are any changes then several deployed coordination is required in the microservice system.

Microservices Tools

  1. Docker: To deploy microservices docker is a slight solution. Using containers helps in creating, deploying, and running the application. And the developers can take advantage of a single package by using these containers.

2. Wiremock: To test Microservices Wiremock is used. It is a library for mocking and stubbing web services. The response which is returned by the HTTP API can be configured after it receives the request.

3. Hystrix: It is a troubleshooting Java library. In an environment like distributed microservices, it is designed in such a way that it helps to separate points. These points are meant to be a 3rd party of libraries.

Some other less-known but useful tools include Cloud Foundry and PaaS.

Micro and Macro Architecture to technical decisions:

  • Micro Architecture: Every decision of microservices is involved in microarchitecture. Hence it makes the app more robust by defining the database by microarchitecture.
  • Macro Architecture: All the decisions involved in macro architecture are made at an international level and are applied to all microservices.

Conclusion

The concept of macro and micro architecture is possible to extend to technical decisions. Hence, by adopting microservices, organizations can achieve greater scalability, flexibility, and faster innovation. As you embark on your microservices journey, remember to experiment, iterate, and continuously improve your architecture to meet the evolving needs of your business.

--

--