Daisy Rees

Daisy Rees


A Beginner's Guide to Microservice Architecture with Example

Learn Microservice Architecture in simple and easy steps starting from basic to advanced concepts with examples

What Is Microservices – Introduction To Microservice Architecture

Have you ever wondered, What is Microservices and how the scaling industries integrate with them while building applications to keep up with their client expectations?

To get an idea of What is Microservices, you have to understand how a monolithic application is decomposed into small tiny micro applications which are packaged and deployed independently. This blog will clear your understanding of how developers use microservices to scale their applications according to their need.

In this article, you will learn about the following:
Why Microservices?What Is Microservices?Features Of Microservice ArchitectureAdvantages Of Microservice ArchitectureBest Practices To Design MicroservicesCompanies Using Microservices##

Why Microservices?

Now, before I tell you about microservices, let’s see the architecture that prevailed before microservices i.e. the Monolithic Architecture.

In layman terms, you can say that its similar to a big container wherein all the software components of an application are assembled together and tightly packaged.

Listed down are the challenges of Monolithic Architecture:

Figure 1: What Is Microservices – Challenges of Monolithic Architecture
Inflexible – Monolithic applications cannot be built using different technologies Unreliable – Even if one feature of the system does not work, then the entire system does not workUnscalable – Applications cannot be scaled easily since each time the application needs to be updated, the complete system has to be rebuiltBlocks Continous Development – Many features of the applications cannot be built and deployed at the same timeSlow Development – Development in monolithic applications take lot of time to be built since each and every feature has to be built one after the other**Not Fit For Complex Applications – **Features of complex applications have tightly coupled dependencies
The above challenges were the main reasons that led to the evolution of microservices.

What Is Microservices?

Microservices, aka Microservice Architecture, is an architectural style that structures an application as a collection of small autonomous services, modeled around a business domain.

** Figure 2**: What Is Microservices – Microservices Representation

In Microservice Architecture, each service is self-contained and implements a single business capability.

Differences Between Traditional Architecture and Microservices

Consider an E-commerce application as a use-case to understand the difference between both of them.

Figure 3: What Is Microservices – Differences Between Monolithic Architecture and Microservices

The main difference we observe in the above diagram is that all the features initially were under a single instance sharing a single database. But then, with microservices, each feature was allotted a different microservice, handling their own data, and performing different functionalities.

Now, let us understand more about microservices by looking at its architecture. Refer the diagram below:

Microservice Architecture

Figure 4: What Is Microservices – Microservice Architecture
Different clients from different devices try to use different services like search, build, configure and other management capabilitiesAll the services are separated based on their domains and functionalities and are further allotted to individual microservicesThese microservices have their own load balancer and execution environment to execute their functionalities & at the same time captures data in their own databasesAll the microservices communicate with each other through a stateless server which is either REST or Message BusMicroservices know their path of communication with the help of **Service Discovery **and perform operational capabilities such as automation, monitoringThen all the functionalities performed by microservices are communicated to clients via API GatewayAll the internal points are connected from the API Gateway. So, anybody who connects to the API Gateway automatically gets connected to the complete system
Now, let us learn more about microservices by looking at its features.

Microservices Features

Figure 5: What Is Microservices – Features Of Microservices
Decoupling – Services within a system are largely decoupled. So the application as a whole can be easily built, altered, and scaledComponentization – Microservices are treated as independent components that can be easily replaced and upgradedBusiness Capabilities – Microservices are very simple and focus on a single capability Autonomy – Developers and teams can work independently of each other, thus increasing speedContinous Delivery – Allows frequent releases of software, through systematic automation of software creation, testing, and approval Responsibility – Microservices do not focus on applications as projects. Instead, they treat applications as products for which they are responsible Decentralized Governance – The focus is on using the right tool for the right job. That means there is no standardized pattern or any technology pattern. Developers have the freedom to choose the best useful tools to solve their problems Agility – Microservices support agile development. Any new feature can be quickly developed and discarded again##

Advantages Of Microservices

Figure 6: What Is Microservices – Advantages Of Microservices
Independent Development – All microservices can be easily developed based on their individual functionalityIndependent Deployment – Based on their services, they can be individually deployed in any application Fault Isolation – Even if one service of the application does not work, the system still continues to functionMixed Technology Stack – Different languages and technologies can be used to build different services of the same applicationGranular Scaling – Individual components can scale as per need, there is no need to scale all components together##

Best Practices To Design Microservices

In today’s world, complexity has managed to creep into products. Microservice architecture promises to keep teams scaling and function better.

The following are the best practices to design microservices:

Figure 7: What Is Microservices – Best Practices To Design Microservices

Now, let us look at a use-case to get a better understanding of microservices.

Use-Case: Shopping Cart Application

Let’s take a classic use case of a shopping cart application.

When you open a shopping cart application, all you see is just a website. But, behind the scenes, the shopping cart application has a service for accepting payments, a service for customer services and so on.

Assume that developers of this application have created it in a monolithic framework.Refer to the diagram below:

Figure 8: What Is Microservices – Monolithic Framework Of Shopping Cart Application

So, all the features are put together in a single code base and are under a single underlying database.

Now, let’s suppose that there is a new brand coming up in the market and developers want to put all the details of the upcoming brand in this application.

Then, they not only have to rework on the service for new labels, but they also have to reframe the complete system and deploy it accordingly.

To avoid such challenges developers of this application decided to shift their application from a monolithic architecture to microservices.Refer to the diagram below to understand the microservices architecture of shopping cart application

Figure 9: What Is Microservices – Microservice Architecture Of Shopping Cart Application

This means that developers don’t create a web microservice, a logic microservice, or a database microservice. Instead, they create separate microservices for search, recommendations, customer services and so on.

This type of architecture for the application not only helps the developers to overcome all the challenges faced with the previous architecture but also helps the shopping cart application to be built, deployed, and scale up easily.

Companies using Microservices

There is a long list of companies using Microservices to build applications, these are just to name a few:

Figure 10: What Is Microservices – Companies Using Microservices

Microservices Tutorial – Learn all about Microservices with Example

Microservices Tutorial

Organizations are quickly moving towards Microservices architecture & hunting for professionals with Microservices Certification. I hope that you have read my previous blog on ***What is Microservices ***that explains the architecture, compares microservices with monolithic and SOA, and also explores when to use microservices with the help of use-cases.

In this Microservices tutorial, the following topics will be covered:

  • Monolithic Architecture
  • Challenges of Monolithic Architecture
  • What is Microservices
  • Microservice Architecture
  • Microservices Example – Demo

Let us explore the concepts of microservices through a use-case on Mediamore.com.

Mediamore is an entertainment company which provides streaming media and videos online. It consists of various genres of TV Shows in different languages. Like many other companies mediamore started its journey with a monolithic architecture.

Let us now explore the monolithic framework of mediamore.

Monolithic Architecture

Figure 11: Monolithic Architecture of Mediamore – Microservices Tutorial

Refer to the above diagram. We can infer that all the features such as the search, user-info, recommendations, video playlist and others are put on a single database using single code.

Now, let me tell you the challenges faced by the developers while using a monolithic framework by using some scenarios.

Challenges of Monolithic Architecture

Scenario 1: Scalability:* Let’s assume that the developers want to update the playlist according to most popular tv shows and also simultaneously want to update all videos to HD quality.*

The developers cannot scale the application simultaneously. New instances of the same application have to be created every time a new feature has to be developed or deployed.

Scenario 2: Agility:* Assume that developers want to make immediate changes in the application.*

The monolithic application can definitely accommodate these changes. But, the problem here is that the developers have to rebuild the code for every small change.

Scenario 3: Hybrid Technologies: Suppose developers of this application are comfortable with various technologies like JAVA, C++,.NET, C#.

Even though they are comfortable with various technologies, they still have to build large and complex applications on a single technology.

Scenario 4: Fault Tolerance:* Let’s suppose that a specific feature is not working in the application.*

The complete system goes down because of this problem. In order to tackle this problem, the application has to be re-built, re-tested and also re-deployed.

So, how did the developers of mediamore overcome these complexities?

Developers thus decided to re-architect their monolithic application into multiple individual deployable components, called as microservices.

Here lies the million dollar question!

What is Microservices?

Microservices is an architecture wherein all the components of the system are put into individual components, which can be built, deployed, and scaled individually.

Let me explain you with a simple analogy.

You must have seen how bees build their honeycomb by aligning hexagonal wax cells. They initially start with a small section using various materials and continue to build a large beehive out of it. These cells form a pattern resulting in a strong structure which holds together a particular section of the beehive. Here, each cell is independent of the other but it is also correlated with the other cells. This means that damage to one cell does not damage the other cells, so, bees can reconstruct these cells without impacting the complete beehive.

Figure 12: Beehive Representation of Microservices – Microservices Tutorial

Refer to the above diagram. Here, each hexagonal shape represents an individual service component. Similar to the working of bees, each agile team builds an individual service component with the available frameworks and the chosen technology stack. Just as in a beehive, each service component forms a strong microservice architecture to provide better scalability. Also, issues with each service component can be handled individually by the agile team with no or minimal impact on the entire application.

The next question that may come to your mind is how do the different components of microservice architecture work together.

But, before that, let me list down the components of the microservice architecture.

Refer to the below diagram.

Figure 13: Microservices Architecture – Microservices Tutorial
Clients – Different users from various devices send requests. Identity Providers – Authenticates user or clients identities and issues security tokens.API Gateway – Handles client requests.Static Content – Houses all the content of the system.Management – Balances services on nodes and identifies failures.Service Discovery – A guide to find the route of communication between microservices.* Content Delivery Networks – Distributed network of proxy servers and their data centers.

  • Remote Service – Enables the remote access information that resides on a network of IT devices.

Let me now brief you on how these components work together on mediamore by considering a scenario.

Microservice Architecture


Alice is an avid user of mediamore. She uses mediamore regularly to watch her favorite series online. She recently missed watching an episode of her favorite TV show.

When Alice logs in to the application, she sees the most recommended content on her home page. After some searching, she finally finds her TV Show.

But, what if Alice wants to get her TV Show with a single click.

How will the developers work together to fulfill Alice’s request?

Alice’s request is passed on to the Identity Provider. Identity provider thus authenticates Alice’s request by identifying her as a regular user on mediamore.

These requests are passed to the API Gateway which acts as an entry point for Alice to forward her requests to the appropriate microservices.

Each feature has its own working microservice, handling their own data. These microservices also have their own** load balancers** and **execution environments **to function properly.

Figure 14: Microservices Architecture of Mediamore – Microservices Tutorial

Refer to the diagram below. Each microservice is handled by a small agile team such as content team, video uploading team, most trending team, search team etc.

Figure 15: Division of Teams of Mediamore – Microservices Tutorial

  • The content team consists of millions of TV Shows that the application provides.
  • The video uploading team have the responsibility to upload all the content into the application
  • The most trending team houses the most trending shows according to the geographical location of users and so on.

These small teams of developers relate each and every piece of content with the metadata that describes the searched content. Then, metadata is fed into another microservice i.e. the search function which ensures Alice’s search results are captures into the content catalog.

Then, the third microservice i.e. most trending microservice captures the trending content among all the mediamore users according to their geographical locations.

The content from this microservice is what Alice sees when she first logs into mediamore.

These individually deployable microservices are put in specific containers to join the application. Containers are used to deliver the code to the sector where deployment is required.

But before they join the application to work together, they have to find each other to fulfil Alice’s request.

How do these microservices find each other?

Microservices use service discovery which acts as a guide to find the route of communication between each of them. Microservices then communicate with each other via a stateless server i.e. either by HTTP Request/Message Bus.

Figure 16: Communication Between Microservices – Microservices Tutorial

These microservices communicate with each other using an Application Program Interface(API). After the Microservices communicate within themselves, they deploy the static content to a cloud-based storage service that can deliver them directly to the clients via Content Delivery Networks (CDNs).

So, when Alice searches for her TV Show, the search microservice communicates with the content catalog service in API about what is Alice searching for and then these microservices compare the typed words with the metadata they already have.

Figure 17: Representation of how to search operation is performed with the help of API – Microservices Tutorial

Once the teams of developers capture the most typed words by Alice, the analytics team update the code in recommendations microservice and compare Alice’s most viewed content and preferences to popular content among other users in the same geographical region.

This means that the next time Alice logs on to the application, she not only sees the most popular content but also finds a personalized playlist which contains the shows she has previously viewed.

In this way, Alice’s request is fulfilled by the development team in a quick manner as they did not have to build the complete application again and just had to update the code to deploy this new functionality.

So this way microservices invoke parallel environments to satisfy millions of customers with varying interests.

Microservices Architecture Example – Demo

To demonstrate the concepts of microservices, I have created 3 Maven Projects called as Doctor_Microservice_Edureka, Diagnosis_Microservice_Edureka, and Patient_Microservice_Edureka using Spring Boot.

Refer to the snapshot below.

Before you understand how these 3 projects interact with each other. Let me brief you on the files of these projects.

To explain this I will consider the project Patient_Microservice_Edureka and list down its basic files.

Refer to the snapshot below.

Pom.xml – Dependencies are added for the creation of REST services.

Application.java – Identical class in all three projects. Acts as an initiator to Spring Boot.

ApplicationConfiguration.java – Research configuration class responsible for exposing REST services for application users.

Patient.java – A simple class consisting of input such as the patient’s name, id, email.

PatientRest.java – Starts the implementation of the REST services in the project.

In this way, similar files are created for the other 2 projects with some additional files in Doctor_Microservice.

REST services are thus created to search patients and the diagnosis. Keys of patient and diagnosis are passed as a parameter to a method(PatientDetails) in Doctor_Microservice.This method gets the data of the patients and diseases.

Refer to the snapshot above. Here, we observe that Patient and Diagnosis classes are included in Doctor_Microservice_Edureka. These classes are cloned from their original projects.

Then to start the REST services, I have initialized **Patient_Microservice_Edureka **on port 8081, Diagnosis_Microservice_Edureka on 8082 and the Doctor_Microservice_Edureka on port 8083.

With the above configurations, when I run each service simultaneously, 3 different console windows run in the Eclipse console window.

As you can see below that after we run the projects, Spring Boot generates a boot log. This log consists information on initializing tomcat and its associated resources. The last line of the log indicates us whether our application has started or not.

To test if the patient and diagnosis services are functioning properly, one a browser (Mozilla Firefox) and go to http://localhost:8081/ and** **http://localhost:8082/ URLs. You should get the outputs as shown below:

Finally, to test the functionality of the Doctor_Microservice_Edureka, I simulated the information of the patient with id 2, suffering from a disease of id 3 and consulting a doctor with consultation 4.

The URL used is as follows: http://localhost:8083/doctor?idPatient=2&idDiagnosis=3&consultation=4

Refer to the snapshot below for the output.

In this way, 3 Microservices interact with each other to produce the desired results.

I hope you have enjoyed reading this Microservices Tutorial. We have seen a simple example to understand how different microservices communicate with each other.

#java #web-development #spring-boot #docker #microservices

What is GEEK

Buddha Community

A Beginner's Guide to Microservice Architecture with Example

Kate Alexenko


Cool writing! I read an article on a similar topic here https://www.cleveroad.com/blog/benefits-of-microservices-architecture I think that this topic is still quite popular, although it seems to me that this is not for long, but what do you think about the prospects for the development of this area?

Serverless Vs Microservices Architecture - A Deep Dive

Companies need to be thinking long-term before even starting a software development project. These needs are solved at the level of architecture: business owners want to assure agility, scalability, and performance.

The top contenders for scalable solutions are serverless and microservices. Both architectures prioritize security but approach it in their own ways. Let’s take a look at how businesses can benefit from the adoption of serverless architecture vs microservices, examine their differences, advantages, and use cases.

#serverless #microservices #architecture #software-architecture #serverless-architecture #microservice-architecture #serverless-vs-microservices #hackernoon-top-story

The Service Mesh in the Microservices World - DZone Microservices

The software industry has come a long journey and throughout this journey, Software Architecture has evolved a lot. Starting with 1-tier (Single-node), 2-tier (Client/ Server), 3-tier, and Distributed are some of the Software Architectural patterns we saw in this journey.

The Problem

The majority of software companies are moving from Monolithic architecture to Microservices architecture, and Microservices architecture is taking over the software industry day-by-day. While monolithic architecture has many benefits, it also has so many shortcomings when catering to modern software development needs. With those shortcomings of monolithic architecture, it is very difficult to meet the demand of the modern-world software requirements and as a result, microservices architecture is taking control of the software development aggressively. The Microservices architecture enables us to deploy our applications more frequently, independently, and reliably meeting modern-day software application development requirements.

#microservice architecture #istio #microservice best practices #linkerd #microservice communication #microservice design #envoy proxy #kubernetes architecture #api gateways #service mesh architecture

Tia  Gottlieb

Tia Gottlieb


What Is a Microservice Architecture? Why Is It Important Now?

We have been building software applications for many years using various tools, technologies, architectural patterns and best practices. It is evident that many software applications become large complex monolith over a period for various reasons. A monolith software application is like a large ball of spaghetti with criss-cross dependencies among its constituent modules. It becomes more complex to develop, deploy and maintain monoliths, constraining the agility and competitive advantages of development teams. Also, let us not undermine the challenge of clearing any sort of technical debt monoliths accumulate, as changing part of monolith code may have cascading impact of destabilizing a working software in production.

Over the years, architectural patterns such as Service Oriented Architecture (SOA) and Microservices have emerged as alternatives to Monoliths.

SOA was arguably the first architectural pattern aimed at solving the typical monolith issues by breaking down a large complex software application to sub-systems or “services”. All these services communicate over a common enterprise service bus (ESB). However, these sub-systems or services are actually mid-sized monoliths, as they share the same database. Also, more and more service-aware logic gets added to ESB and it becomes the single point of failure.

Microservice as an architectural pattern has gathered steam due to large scale adoption by companies like Amazon, Netflix, SoundCloud, Spotify etc. It breaks downs a large software application to a number of loosely coupled microservices. Each microservice is responsible for doing specific discrete tasks, can have its own database and can communicate with other microservices through Application Programming Interfaces (APIs) to solve a large complex business problem. Each microservice can be developed, deployed and maintained independently as long as it operates without breaching a well-defined set of APIs called contract to communicate with other microservices.

#microservice architecture #microservice #scaling #thought leadership #microservices build #microservice

Einar  Hintz

Einar Hintz


Testing Microservices Applications

The shift towards microservices and modular applications makes testing more important and more challenging at the same time. You have to make sure that the microservices running in containers perform well and as intended, but you can no longer rely on conventional testing strategies to get the job done.

This is where new testing approaches are needed. Testing your microservices applications require the right approach, a suitable set of tools, and immense attention to details. This article will guide you through the process of testing your microservices and talk about the challenges you will have to overcome along the way. Let’s get started, shall we?

A Brave New World

Traditionally, testing a monolith application meant configuring a test environment and setting up all of the application components in a way that matched the production environment. It took time to set up the testing environment, and there were a lot of complexities around the process.

Testing also requires the application to run in full. It is not possible to test monolith apps on a per-component basis, mainly because there is usually a base code that ties everything together, and the app is designed to run as a complete app to work properly.

Microservices running in containers offer one particular advantage: universal compatibility. You don’t have to match the testing environment with the deployment architecture exactly, and you can get away with testing individual components rather than the full app in some situations.

Of course, you will have to embrace the new cloud-native approach across the pipeline. Rather than creating critical dependencies between microservices, you need to treat each one as a semi-independent module.

The only monolith or centralized portion of the application is the database, but this too is an easy challenge to overcome. As long as you have a persistent database running on your test environment, you can perform tests at any time.

Keep in mind that there are additional things to focus on when testing microservices.

  • Microservices rely on network communications to talk to each other, so network reliability and requirements must be part of the testing.
  • Automation and infrastructure elements are now added as codes, and you have to make sure that they also run properly when microservices are pushed through the pipeline
  • While containerization is universal, you still have to pay attention to specific dependencies and create a testing strategy that allows for those dependencies to be included

Test containers are the method of choice for many developers. Unlike monolith apps, which lets you use stubs and mocks for testing, microservices need to be tested in test containers. Many CI/CD pipelines actually integrate production microservices as part of the testing process.

Contract Testing as an Approach

As mentioned before, there are many ways to test microservices effectively, but the one approach that developers now use reliably is contract testing. Loosely coupled microservices can be tested in an effective and efficient way using contract testing, mainly because this testing approach focuses on contracts; in other words, it focuses on how components or microservices communicate with each other.

Syntax and semantics construct how components communicate with each other. By defining syntax and semantics in a standardized way and testing microservices based on their ability to generate the right message formats and meet behavioral expectations, you can rest assured knowing that the microservices will behave as intended when deployed.

#testing #software testing #test automation #microservice architecture #microservice #test #software test automation #microservice best practices #microservice deployment #microservice components

Eliseo  Kutch

Eliseo Kutch


MicroServices Architecture Explained Simply | Why to use MicroServices Architecture ?

In this video we will see what is microservices architecture and why developers are prefering this architecture over monolithic architecture.
The architecture is explained in simple way using day to day life example.

#microservices #microservices architecture #explained