Blog

Blog

Top 50 Extraordinary Microservices Interview Questions 2023

Microservices Interview Questions

Microservices Interview Questions

1. List down the advantages of Microservices Architecture.

Here are some advantages of microservices architecture, organized in a table format with descriptions:

AdvantagesDescription
1. Increased flexibility and agilityMicroservices architecture allows for flexibility and agility by allowing developers to work on small, independent units of functionality, which can be developed and deployed quickly.
2. Improved fault isolation and easier debuggingSince microservices are independent and modular, it is easier to isolate and fix issues that may arise in a specific service, rather than having to search through a large, monolithic codebase.
3. Ability to scale specific components independentlyIn a microservices architecture, each service can be scaled independently, based on the specific needs of that service. This allows for more efficient resource utilization and cost savings.
4. Improved maintainability and easier deploymentMicroservices architecture allows for easier maintenance and deployment, as services can be updated and deployed independently of each other, without the need for a complete system shutdown.
5. Ability to use different technologies for different servicesMicroservices architecture allows for the use of different technologies for different services, depending on the specific needs of that service. This allows for more flexibility in choosing the right tools for the job.
6. Improved ability to reuse code and functionalitySince microservices are modular and independent, they can be easily reused in different contexts and across different projects. This can lead to more efficient development and reduced duplication of effort.
7. Improved ability to evolve and modify the system over timeMicroservices architecture allows for a more incremental and evolutionary approach to system development and modification, as changes can be made to individual services without requiring a complete overhaul of the entire system.
8. Improved ability to collaborate and iterate quickly with small, cross-functional teamsMicroservices architecture allows for small, cross-functional teams to work on different services independently, which can lead to faster iteration and collaboration.
9. Improved ability to migrate legacy systems to a microservices architecture gradually, without disruptionMicroservices architecture allows for the gradual migration of legacy systems to a microservices architecture, without the need for a complete system shutdown or disruption of service. This can help to minimize the impact on users and customers.

Please note that microservices architecture is not a silver bullet and may not be suitable for all situations. It is important to carefully consider the trade-offs and potential challenges of using a microservices architecture before deciding to adopt it.

2. What do you know about 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.
  • 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.
Microservices Representation - Microservices Interview Questions - Edureka

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.

3. What are the features of Microservices?

Features of Microservices - Microservices Interview Questions - Edureka

Fig 3: Features of Microservices – Microservices Interview Questions 

  • 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

4. What are the best practices to design Microservices?

The following are the best practices to design microservices:

Best Practices - Microservices Interview Questions - Edureka

Fig 4: Best Practices to Design Microservices – Microservices Interview Questions 

5. How does Microservice Architecture work?

A microservice architecture has the following components:

Working of Microservices Architecture - Microservices Interview Questions - Edureka

Fig 5: Architecture of Microservices – Microservices Interview Questions 

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

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

Pros of Microservice ArchitectureCons of Microservice Architecture
Freedom to use different technologiesIncreases troubleshooting challenges
Each microservices focuses on single capabilityIncreases delay due to remote calls
Supports individual deployable unitsIncreased efforts for configuration and other operations
Allow frequent software releasesDifficult to maintain transaction safety
Ensures security of each serviceTough to track data across various boundaries
Mulitple services are parallelly developed and deployedDifficult to code between services

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

Monolithic vs SOA vs Microservices - Microservices Interview Questions - Edureka

Fig 6: Comparison Between Monolithic SOA & Microservices – Microservices Interview Questions 

  • Monolithic Architecture is similar to a big container wherein all the software components of an application are assembled together and tightly packaged.
  • 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.

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

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.

9. What are the key differences between SOA and Microservices Architecture?

The key differences between SOA and microservices are as follows:

SOAMicroservices
Follows “share-as-much-as-possible” architecture approachFollows “share-as-little-as-possible” architecture approach
Importance is on business functionality reuseImportance is on the concept of “bounded context
They have commongovernance and standardsThey focus on peoplecollaboration and freedom of other options
Uses Enterprise Service bus (ESB) for communicationSimple messaging system
They support multiple message protocolsThey use lightweight protocols such as HTTP/REST etc.
Multi-threaded with more overheads to handle I/OSingle-threaded usually with the use of Event Loop features for non-locking I/O handling
Maximizes application service reusabilityFocuses on decoupling
Traditional Relational Databases are more often usedModern Relational Databases are more often used
A systematic change requires modifying the monolithA systematic change is to create a new service
DevOps / Continuous Delivery is becoming popular, but not yet mainstreamStrong focus on DevOps / Continuous Delivery

10. What are the characteristics of Microservices?

You can list down the characteristics of microservices as follows:

Characteristics of Microservices - Microservices Interview Questions - Edureka

Fig 7: Characteristics of Microservices – Microservices Interview Questions 

You may go through this recording of Microservices Interview Questions and Answers where our instructor has explained the topics in a detailed manner with examples that will help you to understand this concept better.

11. What is Domain Driven Design?

Domain Driven Design - Microservices Interview Questions - Edureka

Fig 8: Principles of DDD – Microservices Interview Questions 

12. Why there is a need for Domain Driven Design (DDD)?

Need for Domain Driven Design - Microservices Interview Questions - Edureka

Fig 9: Factors Why we need DDD – Microservices Interview Questions 

13. What is Ubiquitous language?

Ubiquitous language is a term coined by software developer and author Eric Evans in his book “Domain-Driven Design: Tackling Complexity in the Heart of Software.” It refers to a shared vocabulary that is used consistently throughout a software development project, particularly in the domain model of the application.

The idea behind ubiquitous language is that it helps to align the understanding of the domain between the developers and domain experts, such as business analysts and domain experts. By using a shared vocabulary, everyone involved in the project can communicate more effectively and make fewer misunderstandings.

Ubiquitous language is an important aspect of domain-driven design (DDD), which is a software development approach that focuses on the domain model and emphasizes the importance of understanding the domain in order to design and build effective software systems.

In practice, the use of ubiquitous language involves the creation of a glossary of terms that is used consistently throughout the project, including in code, documentation, and communication between team members. This helps to ensure that everyone is using the same terminology and has a shared understanding of the domain.

14. What is Cohesion?

Cohesion is a measure of the degree to which the elements within a single module or component work together to achieve a single, well-defined purpose. In other words, it refers to the degree to which the elements within a module or component are closely related and work together to achieve a common goal.

High cohesion is generally considered to be a desirable property of a module or component, as it means that the elements within the module or component are closely related and work together in a cohesive manner. This can lead to more maintainable and easier-to-understand code.

On the other hand, low cohesion can be a sign of a poorly-designed module or component, as it may indicate that the elements within the module or component are not closely related and do not work together effectively to achieve a common goal. Low cohesion can lead to more complex and difficult-to-maintain code.

15.  What is Coupling?

Coupling refers to the degree to which one module or component depends on or is connected to another module or component. In other words, it refers to the interdependencies between different modules or components in a system.

High coupling means that one module or component is heavily dependent on or connected to another module or component. This can lead to a system that is difficult to modify or maintain, as changes to one module or component may have unintended consequences on other parts of the system.

On the other hand, low coupling means that one module or component has minimal dependencies on or connections to other parts of the system. This can lead to a system that is more flexible and easier to modify and maintain, as changes to one module or component are less likely to affect other parts of the system.

In general, it is desirable to have low coupling in a system, as it can lead to more modular and flexible design. However, it is also important to ensure that there is sufficient coupling to ensure that the system functions as intended.

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

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.

17. What do you know about Spring Boot?

It’s a knows fact that spring has become more and more complex as new functionalities have been added. If you have to start a new spring project, then you have to add build path or add maven dependencies, configure application server, add spring configuration. So everything has to be done from scratch.

Spring Boot is the solution to this problem. Using spring boot you can avoid all the boilerplate code and configurations. So basically consider yourself as if you’re baking a cake spring is like the ingredients that are required to make the cake and spring boot is the complete cake in your hand.

Spring Boot - Microservices Interview Questions - Edureka

Fig 10: Factors of Spring Boot – Microservices Interview Questions 

18. What is an actuator in Spring boot?

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.

19. What is Spring Cloud?

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).

20. What problems are solved by Spring Cloud?

While developing distributed microservices with Spring Boot we face few issues which are solved by Spring Cloud.

  • The complexity associated with distributed systems – This includes network issues, Latency overhead, Bandwidth issues, security issues.
  • Ability to handle Service Discovery – Service discovery allows processes and services in a cluster to find each other and communicate.
  • Solved redundancy issues – Redundancy issues often occur in distributed systems.
  • Load balancing – Improves the distribution of workloads across multiple computing resources, such as a computer cluster, network links, central processing units.
  • Reduces performance issues – Reduces performance issues due to various operational overheads.

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

The @WebMvcTest annotation is used in Spring MVC applications to test the Spring MVC components of an application, such as controllers, filters, and view resolvers. This annotation can be used in conjunction with the MockMvc class to test the behavior of a controller with mock requests and responses.

Here’s an example of how the @WebMvcTest annotation can be used to test a controller in a Spring MVC application:

Copy code@WebMvcTest(MyController.class)
class MyControllerTest {

  @Autowired
  private MockMvc mockMvc;

  @Test
  void testGetEndpoint() throws Exception {
    this.mockMvc.perform(get("/endpoint"))
        .andExpect(status().isOk())
        .andExpect(content().string("Hello World"));
  }

}

The @WebMvcTest annotation can also be used to test other Spring MVC components, such as filters, view resolvers, and message converters.

It’s important to note that the @WebMvcTest annotation only loads the Spring MVC components and does not load the entire application context. This means that other components and dependencies of the application, such as service layers and repository layers, are not available in the test and must be mocked or stubbed as necessary.

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

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.

23. What are different types of Tests for Microservices?

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.

24. What do you understand by Distributed Transaction?

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.

25. What is an Idempotence and where it is used?

Idempotence is the property of being able to do something twice in such a way that the end result will remain the same i.e. as if it had been done once only.

Usage: Idempotence is used at the remote service, or data source so that, when it receives the instruction more than once, it only processes the instruction once.

26. What is Bounded Context?

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.

27. What is Two Factor Authentication?

Two-factor authentication enables the second level of authentication to an account log-in process.

2 Factor Authentication - Microservices Interview Questions - Edureka

Fig11: Representation of Two Factor Authentication – Microservices Interview Questions 

So suppose a user has to enter only username and password, then that’s considered a single-factor authentication.

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

The three types of credentials are:

Types of Credentials - Microservices Interview Questions - Edureka

Fig 12: Types of Credentials of Two Factor Authentication – Microservices Interview Questions 

29. What are Client certificates?

A type of digital certificate that is used by client systems to make authenticated requests to a remote server is known as the client certificate. Client certificates play a very important role in many mutual authentication designs, providing strong assurances of a requester’s identity.

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

PACT is 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.

31. What is OAuth?

OAuth stands for open authorization protocol. This allows accessing the resources of the resource owner by enabling the client applications on HTTP services such as third-party providers Facebook, GitHub, etc. So with this, you can share resources stored on one site with another site without using their credentials.

32. What is Conway’s law?

“Any organization that designs a system (defined broadly) will produce a design whose structure is a copy of the organization’s communication structure.” – Mel Conway

Conway's Law - Microservices Interview Questions - Edureka

Fig 13: Representation of Conway’s Law – Microservices Interview Questions 

This law basically tries to convey the fact that, in order for a software module to function, the complete team should communicate well. Therefore the structure of a system reflects the social boundaries of the organization(s) that produced it.

33. What do you understand by Contract Testing?

According to Martin Flower, contract test is a test at the boundary of an external service which verifies that it meets the contract expected by a consuming service.

Also, contract testing does not test the behavior of the service in depth. Rather, it tests that the inputs & outputs of service calls contain required attributes and the response latency, throughput is within allowed limits.

34. What is End to End Microservices Testing?

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.

Microservices Testing - Microservices Interview Questions - Edureka

Fig 14: Hierarchy of Tests – Microservices Interview Questions 

35. What is the use of Container in Microservices?

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.

Container in Microservices - Microservices Interview Questions - Edureka

Fig 15: Representation of Containers and How they are used in Microservices – Microservices Interview Questions 

36. What is DRY in Microservices architecture?

DRY stands for Don’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.

37. What is a Consumer-Driven Contract (CDC)?

This is basically a pattern for developing Microservices so that they can be used by external systems. When we work on microservices, there is a particular provider who builds it and there are one or more consumers who use Microservice.

Generally, providers specify the interfaces in an XML document. But in Consumer Driven Contract, each consumer of service conveys the interface expected from the Provider.

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

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.

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

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

40. How can we perform Cross-Functional testing?

Cross-functional testing is a verification of non-functional requirements, i.e. those requirements which cannot be implemented like a normal feature.

41. How can we eradicate non-determinism in tests?

Non-Deterministic Tests (NDT)  are basically unreliable tests.  So, sometimes it may happen that they pass and obviously sometimes they may also fail. As and when they fail, they are made to re-run to pass.

Some ways to remove non-determinism from tests are as follows:

  1. Quarantine
  2. Asynchronous
  3. Remote Services
  4. Isolation
  5. Time
  6. Resource leaks

42. What is the difference between Mock or Stub?

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.

43. What do you know about Mike Cohn’s Test Pyramid?

Mike Cohn provided a model called Test Pyramid. This describes the kind of automated tests required for software development.

Mike Cohn's Test Pyramid - Microservices Interview Questions - Edureka

Fig 16: Mike Cohn’s Test Pyramid – Microservices Interview Questions

As per pyramid, the number of tests at first layer should be highest. At service layer, the number of tests should be less than at the unit test level, but more than at the end-to-end level.

44. What is the purpose of Docker?

Docker provides a container environment that can be used to host any application. In this, the software application and the dependencies which support it are tightly-packaged together.

So, this packaged product is called a Container and since it is done by Docker, it is called Docker container!

45. What is Canary Releasing?

Canary Releasing is a technique to reduce the risk of introducing a new software version in production. This is done by slowly rolling out the change to a small subset of users before giving it out to the entire infrastructure, i.e. making it available to everybody.

46. What do you mean by Continuous Integration (CI)?

Continuous Integration (CI) is the process of automating the build and testing of code every time a team member commits changes to version control. This encourages developers to share code and unit tests by merging the changes into a shared version control repository after every small task completion.

47. What is Continuous Monitoring?

Continuous monitoring gets into the depth of monitoring coverage, from in-browser front-end performance metrics, through application performance, and down to host virtualized infrastructure metrics.

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

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.

49. Can we create State Machines out of Microservices?

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.

50. What are Reactive Extensions in Microservices?

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.

Select the fields to be shown. Others will be hidden. Drag and drop to rearrange the order.
  • Image
  • SKU
  • Rating
  • Price
  • Stock
  • Availability
  • Add to cart
  • Description
  • Content
  • Weight
  • Dimensions
  • Additional information
Click outside to hide the comparison bar
Compare

Subscribe to Newsletter

Stay ahead of the rapidly evolving world of technology with our news letters. Subscribe now!