Corporate Training
Request Demo
Click me
Menu
Let's Talk
Request Demo

Microservices Interview Questions and Answers

by Sathish, on Jul 20, 2022 8:16:54 PM

Microservices Interview Questions and Answers

1.What do you know about Microservices?

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

  • In layman terms, 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.

 

                       

 

         Fig 1: Beehive Representation of Microservices – Microservices Interview Questions

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.

2.What are the features of Microservices?.

  • Decoupling – Services within a system are largely decoupled. So the application as a whole can be easily built, altered, and scaled
  • Componentization – Microservices are treated as independent components that can be easily replaced and upgraded
  • Business Capabilities – Microservices are very simple and focus on a single capability
  • Autonomy – Developers and teams can work independently of each other, thus increasing speed
  • Continous 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

3.How does Microservice Architecture work?

Ans: A microservice architecture has the following components:

 

  • 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 IT devices.

4.What are the challenges you face while working Microservice Architectures?

Ans:  Developing a number of smaller microservices sounds easy, but the challenges often faced while developing them are as follows.

  • Automate the Components: Difficult to automate because there are a number of smaller components. So for each component, we have to follow the stages of  Build, Deploy and, Monitor.
  • Perceptibility: Maintaining a large number of components together becomes difficult to deploy, maintain, monitor and identify problems. It requires great perceptibility around all the components.
  • Configuration Management: Maintaining the configurations for the components across the various environments becomes tough sometimes.
  • Debugging: Difficult to find out each and every service for an error. It is essential to maintain centralized logging and dashboards to debug problems.

5.What is the difference between Monolithic, SOA and Microservices Architecture?

Ans:  Monolithic Architecture is similar to a big container wherein all the software components of an application are assembled together and tightly packaged.

        A Service-Oriented Architecture is a collection of services which communicate with each other. The communication can involve either simple data passing or it could involve two or more services coordinating some activity.
       Microservice Architecture is an architectural style that structures an application as a collection of small autonomous services, modeled around a business domain.

6.What are the pros and cons of Microservice Architecture?

Pros of Microservice Architecture Cons of Microservice Architecture
Freedom to use different technologies Increases troubleshooting challenges
Each microservices focuses on single capability Increases delay due to remote calls
Supports individual deployable units Increased efforts for configuration and other operations
Allow frequent software releases Difficult to maintain transaction safety
Ensures security of each service Tough to track data across various boundaries
Mulitple services are parallelly developed and deployed Difficult to code between services

 

7.Can we create State Machines out of Microservices?

 Ans: As we know that each Microservice owning its own database is an independently deployable program unit, this, in turn, lets us create a State Machine out of it. So, we can specify different states and events for a particular microservice.

For Example, we can define an Order microservice. An Order can have different states. The transitions of Order states can be independent events in the Order microservice.

8.What are different types of Tests for Microservices?

Ans:While working with microservices, testing becomes quite complex as there are multiple microservices working together. So, tests are divided into different levels.

  • At the bottom level, we have technology-facing tests like- unit tests and performance tests. These are completely automated.
  • At the middle level, we have tests for exploratory testing like the stress tests and usability tests.
  • At the top level, we have acceptance tests that are few in number. These acceptance tests help stakeholders in understanding and verifying software features.

9. Can you give a gist about Rest and Microservices?

Ans:

REST  Though you can implement microservices in multiple ways, REST over HTTP is a way to implement Microservices. REST is also used in other applications such as web apps, API design, and MVC applications to serve business data.

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. There are certain principles and best practices of Microservices that help in building a resilient application.

In a nutshell, you can say that REST is a medium to build Microservices.

10.What is Bounded Context?

Ans:  Bounded Context is a central pattern in Domain-Driven Design. It is the focus of DDD’s strategic design section which is all about dealing with large models and teams. DDD deals with large models by dividing them into different Bounded Contexts and being explicit about their inter-relationships.

11.What do you understand by Distributed Transaction?

Ans:   Distributed Transaction is any situation where a single event results in the mutation of two or more separate sources of data which cannot be committed atomically. In the world of microservices, it becomes even more complex as each service is a unit of work and most of the time multiple services have to work together to make a business successful.

12.What are the types of credentials of Two Factor Authentication?

The Two types of credentials are:

  • Type 1 – Something You Know – includes passwords, PINs, combinations, code words, or secret handshakes. ...
  • Type 2 – Something You Have – includes all items that are physical objects, such as keys, smart phones, smart cards, USB drives, and token devices.               

13.What is the use of PACT in Microservices architecture?

Ans: PACTis an open source tool to allow testing interactions between service providers and consumers in isolation against the contract made so that the reliability of Microservices integration increases.

Usage in Microservices:

  • Used to implement Consumer Driven Contract in Microservices.
  • Tests the consumer-driven contracts between consumer and provider of a Microservice.

14.What is End to End Microservices Testing?

Ans:  End-to-end testing validates each and every process in the workflow is functioning properly. This ensures that the system works together as a whole and satisfies all requirements.

In layman terms, you can say that end to end testing is a kind of tests where everything is tested after a particular period.

15.What is the use of Container in Microservices?

Ans: Containers are a good way to manage microservice based application to develop and deploy them individually. You can encapsulate your microservice in a container image along with its dependencies, which then can be used to roll on-demand instances of microservice without any additional efforts required.

16.What is DRY in Microservices architecture?

Ans: DRYstands forDon’t Repeat Yourself. It basically promotes the concept of reusing the code. This results in developing and sharing the libraries which in turn result in tight coupling.

17.What is the role of Web, RESTful APIs in Microservices?

Ans: A microservice architecture is based on a concept wherein all its services should be able to interact with each other to build a business functionality. So, to achieve this, each microservice must have an interface. This makes the web API a very important enabler of microservices. Being based on the open networking principles of the Web, RESTful APIs provide the most logical model for building interfaces between the various components of a microservice architecture.

18.What do you understand by Semantic monitoring in Microservices architecture?

Ans: Semantic monitoring, also known as synthetic monitoring combines automated tests with monitoring the application in order to detect business failing factors.

19.What is the difference between Mock or Stub?

Ans:  Stub

  • A dummy object that helps in running the test.
  • Provides fixed behavior under certain conditions which can be hard-coded.
  • Any other behavior of the stub is never tested.

For example, for an empty stack, you can create a stub that just returns true for empty() method. So, this does not care whether there is an element in the stack or not.

      Mock

  • A dummy object in which certain properties are set initially.
  • The behavior of this object depends on the set properties.
  • The object’s behavior can also be tested.

For example, for a Customer object, you can mock it by setting name and age. You can set age as 12 and then test for isAdult() method that will return true for age greater than 18. So, your Mock Customer object works for the specified condition.

20What are Reactive Extensions in Microservices?

Ans:   Reactive Extensions also are known as Rx. It is a design approach in which we collect results by calling multiple services and then compile a combined response. These calls can be synchronous or asynchronous, blocking or non-blocking. Rx is a very popular tool in distributed systems which works opposite to legacy flows.

Hope these Microservices Interview Questions would help you in your Microservices Architect Interviews.

If you wish to learn Microservices and build your own applications, then check out our Microservices Architecture Training which comes with instructor-led live training and real-life project experience. This training will help you understand Microservices in depth and help you achieve mastery over the subject.

21.What is the role of an architect in Microservices architecture?

Ans:  An architect in microservices architecture plays the following roles:

  • Decides broad strokes about the layout of the overall software system.
  • Helps in deciding the zoning of the components. So, they make sure components are mutually cohesive, but not tightly coupled.
  • Code with developers and learn the challenges faced in day-to-day life.
  • Make recommendations for certain tools and technologies to the team developing microservices.
  • Provide technical governance so that the teams in their technical development follow principles of Microservice.

22.What is the use of WebMvcTest annotation in Spring MVC applications?

WebMvcTest annotation is used for unit testing Spring MVC Applications in cases where the test objective is to just focus on Spring MVC Components. In the snapshot shown above, we want to launch only the ToTestController. All other controllers and mappings will not be launched when this unit test is executed.

23.What is an actuator in Spring boot?

Ans: Spring Boot actuator provides restful web services to access the current state of running an application in the production environment. With the help of actuator, you can check various metrics and monitor your application.

24.What is Spring Cloud?

Ans: According to the official website of Spring Cloud, Spring Cloud provides tools for developers to quickly build some of the common patterns in distributed systems (e.g. configuration management, service discovery, circuit breakers, intelligent routing, leadership election, distributed sessions, cluster state).

25.What is REST/RESTful and what are its uses?

Ans:  Representational State Transfer (REST)/RESTful web services are an architectural style to help computer systems communicate over the internet. This makes microservices easier to understand and implement.

Microservices can be implemented with or without RESTful APIs, but it’s always easier to build loosely coupled microservices using RESTful APIs.

26.What is Ubiquitous language?

Ans: If you have to define the Ubiquitous Language (UL), then it is a common language used by developers and users of a specific domain through which the domain can be explained easily.

The ubiquitous language has to be crystal clear so that it brings all the team members on the same page and also translates in such a way that a machine can understand.

 

Comments

Subscribe

Top Courses in Python

Top Courses in Python

We help you to choose the right Python career Path at myTectra. Here are the top courses in Python one can select. Learn More →

aathirai cut mango pickle

More...