Part 2: Microservices Interview Questions And Answers

Himaanshu Shukla
7 min readJun 12, 2022

--

Name three commonly used tools for Microservices
Wiremock, Docker, and Hystrix are important Microservices tools.

Why do we need Containers for Microservices?
To manage a microservice-based application, containers are the easiest alternative. They play a crucial role in the deployment and management of microservices architectures.

a). Isolation: Containers encapsulate the application and its dependencies, providing a lightweight, isolated environment. Each microservice can run in its own container, ensuring that it has everything it needs to operate without interfering with other services. This isolation helps in avoiding conflicts between dependencies and provides consistency across different environments.

b). Scalability: Containers are designed to be easily scalable. Microservices often require dynamic scaling to handle varying workloads. Containers can be quickly started or stopped, making it easier to scale individual microservices independently based on demand. This elasticity allows for efficient resource utilization and cost management.

c). Portability: Containers are highly portable and can run consistently across various environments, including development, testing, and production. This ensures that a microservice behaves the same way regardless of the underlying infrastructure. This portability simplifies the deployment process and supports a “write once, run anywhere” philosophy.

d). Orchestration: Microservices often involve the coordination and orchestration of multiple services. Container orchestration tools, such as Kubernetes and Docker Swarm, help manage the deployment, scaling, and lifecycle of containers. They automate tasks like load balancing, service discovery, and rolling updates, simplifying the management of complex microservices architectures.

e). Dependency Management: Containers package an application along with its dependencies, libraries, and runtime, ensuring that the microservice runs consistently across different environments. This helps eliminate the common problem of “it works on my machine” by creating a consistent environment from development to production.

f). Fast Deployment: Containers can be started or stopped quickly, allowing for fast deployment and updates. This agility is crucial for microservices, where frequent updates and releases are common. It supports practices like continuous integration and continuous deployment (CI/CD), facilitating a more agile and responsive development process.

What is the use of Docker?
Docker offers a container environment that can be used to host any application. This software application and the dependencies that support it are tightly packaged together.

What are the main components of Microservices?

  • Containers, Clustering, and Orchestration
  • IaC [Infrastructure as Code Conception]
  • Cloud Infrastructure
  • API Gateway
  • Enterprise Service Bus
  • Service Delivery

What do you know about Spring Boot?
It’s a known 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 a build path or add maven dependencies, configure the application server, and 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. If you are cooking a dish, the ingredients can be considered to be Spring. While Spring Boot is a completely cooked recipe.

Which Embedded Containers Are Supported By Spring Boot?
Whenever you are creating a Java Application, deployment can be done by 2 methods: By using an application container that is external or we can also embed the container inside your jar file.

Spring Boot contains Jetty, Tomcat, and Undertow servers, all of which are embedded.

How to configure Spring Boot application logging?
Spring Boot comes with added support for Log4J2, Java Util Logging, and Logback. It is usually pre-configured as console output. They can be configured by only specifying logging.level in the application.properties file.

logging.level.spring.framework=Debug

What is the role of the 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 an actuator, you can check various metrics and monitor your application.

What is Spring Cloud?
Spring Cloud in Microservices, is a system that provides integration with external systems. It allows microservices framework to build applications that perform restricted amounts of data processing.

Spring Cloud provides some out-of-the-box experience and a set of extensive features mentioned below:

  • Versioned and distributed configuration
  • Discovery of the service registration
  • service-to-service calls
  • Routing
  • Circuit breakers and load balancing
  • Cluster state and leadership election
  • Global locks and distributed messaging

What problems are solved by Spring Cloud?

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

How do independent micro-services communicate with each other?
It depends upon your project needs. However, in most cases, developers use HTTP/REST with JSON or Binary protocol. However, they can use any communication protocol.

In which cases microservice architecture best suited?
Microservice architecture is best suited for desktops, web, mobile devices, Smart TVs, wearables, etc.

What are the characteristics of Microservices?

  • Essential messaging frameworks
  • Decentralized Governance
  • Easy Infrastructure automation
  • Design for failure
  • Infrastructure automation

Explain three types of Tests for Microservices?

  • At the bottom level test, we can perform general tests like performance and unit tests. These kinds of tests are entirely automated.
  • At the middle level, we can perform exploratory tests like stress tests and usability tests.
  • At the top level, we can conduct acceptance tests which are mostly fewer in numbers. It also helps stakeholders to know about different software features.

Explain the use of PACT in Microservices architecture? How does PACT work?
A contract between a consumer application and a provider application is called a PACT. Each pact is a collection of interactions.

It is an open-source tool that can be used to implement the Consumer-Driven Contract in Microservices. However, it is separated from the contract made. This increases the reliability of the Microservices applications.

The consumer service developer starts by writing a test that defines a mode of interaction with the service provider. The test includes the provider’s state, the request body, and the response that is expected. Based on it, PACT creates a stub against which the test is executed. The output is stored in a JSON file.

What is Contract Testing?
Contract Testing ensures that the explicit and implicit contracts of a microservice architecture work as expected. There are two perspectives to contract to test — Consumer and Provider. The consumer is the [application] entity using the microservice, and the provider is the [application] entity providing the service. Such services work under predefined specifications, and contract testing ensures so.

What are Client Certificates?
Client certificates are digital certificates used to make authenticated requests to a remote server.

What is the meaning of OAuth?
OAuth means open authorization protocol. This protocol allows you to access the client applications on HTTP for third-party providers GitHub, Facebook, etc. It helps you to share resources stored on one site with another site without the need for their credentials.

What is the meaning of Semantic monitoring in Microservices architecture?
Semantic monitoring, also known as synthetic monitoring combines monitoring of the entire application along with automated tests.

The primary benefit of Semantic Monitoring is to find out the factors which are more profitable to your business. It allows you to find out the reasons why your business is not getting more profits.

What is Domain Driven Design?
Domain-Driven Design is an architectural style based on an Object-Oriented Analysis of Design concepts and principles. It helps in developing a complex system by connecting the related components of the software system into a continuously evolving system. Domain-Driven Design is based on three core principles:

  • Focus on the core domain and domain logic.
  • Base complex designs on models of the domain.
  • Regularly collaborate with the domain experts to improve the application model and resolve any emerging domain-related issues.

What do you mean by Bounded Context?

A central pattern is usually seen in domain-driven design(DDD), Bounded Context is the main focus of the strategic design section of DDD. It is all about a deal with large teams and models. DDD works with large models by disintegrating them into multiple bounded contexts. While it does that, it also explains the relationship between them explicitly.

What is Ubiquitous language?
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.

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

What Do You Mean By End-To-End Testing Of Microservices?
End to End testing validates all the processes in the workflow to check if everything is working properly as expected. It also ensures that the system works in a unified manner, thereby satisfying the business requirement.

Why Would You Need Reports & Dashboards In Microservices?
Reports and dashboards are mainly used to monitor and upkeep microservices. There are multiple tools that help to serve this purpose. Reports and dashboards can be used to:

  • find out which microservices expose what resources.
  • find out the services which are impacted whenever changes in a component occur.
  • provide an easy point that can be accessed whenever documentation is required.
  • Versions of the components which are deployed.
  • To obtain a sense of maturity and compliance from the components.

Microservices Interview Questions And Answers

Did you know you could give up to 50 claps?
Yes, 50 claps, isn’t it awesome. If you feel my posts are interesting or helpful to you, please do press the 👏 clap button and share/ follow, and help others find this story too. Also, feel free to leave a comment below.

If you enjoyed reading my blogs, I’d appreciate it if you’d buy me a coffee

Keep learning and growing!
- Himanshu Shukla..

--

--

Himaanshu Shukla

Software Engineer | Certified Scrum Master | Angel Therapy Practitioner| Light Worker| Empath | Buy me a coffee https://ko-fi.com/greekykhs |Blogger