Micro-services interview questions for experienced/Microservice Interview Questions and Answers for Freshers & Experienced

Why do Microservices require a DevOps approach??

One of the key benefits of Microservice architecture is speed. It is the ability to iterate quickly on individual services as individual services can be developed and deployed independently. DevOps enables to achieve speed through people, process, and technology change. DevOps for microservices helps to move away from long release cycles of monolith application(s) by increasing the velocity.

It is possible to automate almost every element in the path to production. DevOps practices like DevOps pipeline creation, continuous integration, and continuous delivery are used to drive microservice deployments.

Quick production helps in the creation of software as a service (SaaS) business models where the customer pays for access to a continuously improving system.

DevOps helps microservice architecture with the below.

1. Faster service delivery
2. Visibility across data
3. Cost-effective service
4. Seamless conversion or upgrade

Posted Date:- 2021-09-24 06:12:44

What is a bounded context in microservices?

The bounded context concept comes from Domain-driven design (DDD) for microservices. Domain-driven design defines a data model for every microservice to which that service is responsible for and is bound.

Every microservice owns this data and is responsible for that data’s integrity and mutability.

Microservices are designed on the architectural principle of ‘Share as little as possible. Every microservice has its data and communicates with other services and clients only via a well-defined interface. Every microservices is independently developed, deployed, and maintained. So Microservices are resilient to failure.

Posted Date:- 2021-09-24 06:11:39

What is the Service Discovery pattern in microservices?

In the case of Microservices, issues for calling services need to be addressed.

With container technology, serverless architecture, IP addresses can be dynamically allocated to service instances. When address changes, consumer service can break and will need changes.

This issue can be solved by a service registry. Service registry will keep metadata of every producer service in the ecosystem. A service instance needs to register to the registry whenever it starts and should de-register when shutting down. Consumer service can query the Service registry every time it needs to find out the location of the service. This is called the Service Discovery pattern.

Posted Date:- 2021-09-24 06:10:53

What is a Log aggregator pattern in Microservices?

Log aggregation is an Observability pattern in microservice. In the case of a distributed transaction in a microservices architecture, every service instance will generate a log file in a standard format. Unless the logs are centralized, it becomes difficult to understand the application behavior from the logs.

Log aggregation pattern solves this issue. A centralized logging service aggregates logs from every service instance. In the case of Elastic Stack, the logs are indexed as well. Users will be able to search and analyze the logs. Alerts can be triggered whenever certain messages appear in the logs.

Fluentd is a logging agent which can aggregate logs.

In the case of Amazon web services, AWS Cloud Watch does the same.

Posted Date:- 2021-09-24 06:10:09

What tools can be used for monitoring microservices?

Monitoring of microservices is complex due to its distributed nature. Some of the tools used for monitoring microservices are given below.

Jaeger is a tracing tool that can be used for end-to-end distributed tracing. Distributed transactions can be monitored to find dependencies between services, isolation of performance bottleneck, and help in performance optimization.

Prometheus is a metrics monitoring tool with a time-series database. Metrics can be displayed in a graphical format in Prometheus.

Fluentd is a log collecting agent for collecting, aggregating, and exporting logs to central log storage.

Grafana is used for analytics and monitoring and provides different visualization formats.

APM tool – Application performance monitoring can correlate logs, metrics, and traces and identify unknown issues in the services and can be used for distributed tracing to identify application performance bottlenecks, analytics, predictions based on AI ML capabilities, etc. Eg. Elastic APM, NewRelic, AppDynamics, DynaTrace.

Posted Date:- 2021-09-24 06:09:31

How to secure microservices?

There are different ways to secure microservices. Some of the ways to secure microservices are given below.

* Using OAuth for user identity and role-based access control.
* Apply different layers of security by identifying the most sensitive services.
* Use encryption using NaCl or libsodium. Don’t invest in coming up with new encryption or decryption algorithm.
* A distributed firewall with centralized control is required. Granular control over every microservice is required.
* Use API gateway to secure the microservices behind a firewall.
* Monitor all with a reliable monitoring platform.

Posted Date:- 2021-09-24 06:08:48

What is feign client in microservices?

Feign is a declarative web service from Netflix. Feign client provides an abstraction over Rest based calls via annotation, through which microservices will be able to communicate with each other without the need for writing detailed REST client code.

Feign simplifies the client code so much that we only need to define a proxy and define a single method into the proxy.

Posted Date:- 2021-09-24 06:06:34

What are the most common mistakes while transitioning to Microservices?

The common mistakes done while transitioning to a microservices architecture as given below.

* The main challenges are not outlined properly.
* End up rewriting already existing functionalities/programs
* Automation is not considered and identified
* The vague definition of boundaries and timeline
* Big bang approach in transition instead of starting small

Posted Date:- 2021-09-24 06:05:39

Which acts as a database of services in microservices?

Service Registry is a database that contains the network locations of the service instance and helps in service discovery. It is critical that a service registry needs to be highly available and always up to date.

Whenever any service starts, it needs to register itself with the Discovery server. . Netflix Eureka is a good example of a service registry.

Posted Date:- 2021-09-24 06:04:35

How are the problems with distributed transactions addressed in microservices?

In the microservices world, a distributed transaction is a transaction that is distributed across multiple services and the microservices could be called in a sequence to complete one entire transaction.

In case of any failure in any one of the transactions in a distributed transaction, the actions before the failure will need to be reversed. If not reversed, it will lead to data inconsistency across multiple services. Saga pattern helps in addressing this problem.

Posted Date:- 2021-09-24 06:03:51

What is a circuit breaker pattern in Microservices?

Circuit Breaker is a microservice design pattern. In a microservices architecture, it is typical that a request could span multiple services. For any request, if one of the services involved in the response is not working, a circuit Breaker is used to stop the process of request and response.

Without a circuit breaker in place, the client would have continuously sent requests to the service which is down. Resources will get exhausted with low performance and a bad user experience due to this. To avoid this kind of problem, a circuit breaker pattern can be used.

In the case of a circuit breaker pattern, the client will invoke a remote service via a proxy. This proxy will behave as a circuit barrier. In case of failure, when the number of failures crosses a defined threshold number, the circuit breaker will trip for a defined period. During this time, requests to invoke remote service will fail. Once the time-out period for the breaker is complete, a circuit breaker will allow a defined number of tests to pass through, and only when they succeed, a circuit breaker will resume back to normal operation and will start fulfilling the requests.

Posted Date:- 2021-09-24 06:03:19

What is the CQRS pattern in microservice??

CQRS stands for Command Query Responsibility Segregator. Every microservice as per design will have a database per service model or shared database per service. As applications become more complex, the handling of detailed queries and validations also more complex. Traditional CRUD (Create, Read, Update and Delete) data model will become cumbersome to implement and maintain.

CQRS pattern proposes the separation of the read data model (Read) from the writing data model (Create, Update and Delete). The application will be segregated into Command and Query parts. The command part will be responsible for the Create, update, and delete operations. The query part will be responsible for the read operation through materialized views. This segregation provides scalability, ease of maintenance, and optimization of the database.

Posted Date:- 2021-09-24 06:02:47

What is a saga pattern in microservices?

In the case of microservices architecture, it is typical that a user’s request can span multiple services. Saga pattern is a microservice architectural pattern to implement a transaction that can span across multiple services.

Every service in a saga performance its transaction for the request and publishes an event. Other services listen to the published event and perform the next local transaction. If any of the transactions in the end-to-end flow fails for any reason, the saga pattern implementation will execute required transactions to undo the impact of preceding transactions.

Saga pattern is very useful in maintaining data consistency across multiple services in a microservices architecture.

Posted Date:- 2021-09-24 06:02:12

Efficient utilization & fast deployment represent which pattern in microservices?

Efficient utilization & fast deployment represents Multiple Service Instances per Host.

Multiple Service Instances per Host is a traditional approach to deploy an application. As part of this pattern, single or multiple physical or virtual hosts are provisioned and then several service instances are run on each host.

This pattern provides relatively efficient usage as multiple service instances use the same server and the underlying operating system.

Service deployment is also fast as it is required to copy the service to a host and simply run it.

Posted Date:- 2021-09-24 06:00:44

What is Tasklet, and what is a Chunk? ↑

The Tasklet is a simple interface with one method to execute. A tasklet can be used to perform single tasks like running queries, deleting files, etc. In Spring Batch, the tasklet is an interface that can be used to perform unique tasks like clean or set up resources before or after any step execution.

Spring Batch uses a ‘Chunk Oriented’ processing style within its most common implementation. Chunk Oriented Processing refers to reading the data one at a time and creating chunks that will be written out, within a transaction boundary.

Posted Date:- 2021-09-24 05:59:21

What is blue/green deployment?

There are two complete environments in blue, green deployment. Blue is the running environment, and green is the one which you want to upgrade. Once the environment is swapped, traffic is directed to the new green environment. The old blue environment can be saved for backup or deleted.

Posted Date:- 2021-09-24 05:57:46

What is load balancing in Spring Cloud?

Load balancing in computing improves workload distribution across multiple computing resources. It aims to maximize throughput, optimize resource use, avoid overloading a single resource and minimize response time. In Spring Cloud, load balancing can be implemented using Netflix Ribbon.

Posted Date:- 2021-09-24 05:57:16

What factors make one hesitant to use microservices?

Microservices require heavy investment and heavy architecture set up. They have autonomous staff selection and need excessive planning for handling operations overhead.

Posted Date:- 2021-09-24 05:56:44

List some of the best practices to design Microservices.

1. Separating build for each microservice.

2. Deploying into containers.

3. Treating servers as stateless.

4. Keeping code at a similar level of maturity.

5. Separating data store for each microservice.

Posted Date:- 2021-09-24 05:56:15

Briefly tell about serverless deployment strategy of Microservices deployment.

In serverless deployment, the service is packaged as a ZIP file and uploaded to the Lambda function- a stateless service that can run enough microservices automatically to handle all requests.

Posted Date:- 2021-09-24 05:55:06

What are the three types of tests for Microservices?

The first test is the bottom level test that performs general test like unit and performance tests. At the middle level, experimental tests like usability and stress tests are there. Moreover, at the top level, acceptance testing takes place. Tests at all levels are automated.

Posted Date:- 2021-09-24 05:54:37

What is a ‘dumb pipe’ in Microservices?

Dumb pipes mean that no further actions can be taken place in this communication means. It just carries the data across a channel, and it is replaceable. The infrastructure is dumb, i.e. it can only act as a message router, and it has no other functions.

Posted Date:- 2021-09-24 05:54:10

How to implement microservices in java?

For developing microservices using Java, there are several microservices frameworks. Some of the examples for java based microservices development are given below.

a. Spring Boot: This is one of the best Java microservices frameworks that work on top of languages for Inversion of Control, Aspect-Oriented Programming, etc.

b. Jersey: This is an open-source framework that supports JAX-RS APIs in Java and is very easy to use.

c. Swagger: Swagger helps in documenting API and provides a development portal. Swagger allows users to test the developer APIs.

Additionally, frameworks like Dropwizard, Ninja Web Framework, Rest, Play Framework, RestExpress, Restlet, and Spark Framework can also be used for the development of microservices using Java.

Posted Date:- 2021-09-24 05:53:25

How to deploy microservices?

Microservices are developed and deployed quickly and in most cases automatically as part of the CI/CD pipeline. Microservices could be deployed in Virtual Machines or Containers. The virtual machines or containers can be On-premise or in the cloud as well.

There are different deployment approaches available for Microservices. Some of the possible deployment approaches for microservices are mentioned below.

* Multiple service instances per host
* Service instance per host
* Service instance per VM
* Service instance per Container
* Serverless deployment
* Service deployment platform

Posted Date:- 2021-09-24 05:52:56

Why are containers a good infrastructure for microservices?

Containers are lightweight, easily packaged, and are designed to run anywhere. Containers provide execution isolation at the operating system level. Single Operating system instance can support multiple containers with each container having its separate execution environment.

Containers are not mandatory as part of microservices architecture. For example, Netflix runs its microservices-based offerings on Amazon web services using AWS instance.

Fine-grained execution environments of containers and the ability of the container to accommodate co-located application components in the same operating system instance help greatly in achieving better server utilization rates. If any organization has the application of its microservices in the cloud environment, this will help in reducing the bills.

Container-based microservices applications can respond better to erratic workloads. Container initiation time is shorter, and this will help in user satisfaction.

Posted Date:- 2021-09-24 05:52:05

What is Spring Cloud Gateway? What are its advantages over Netflix Zuul

Zuul is a blocking API. A blocking gateway api makes use of as many threads as the number of incoming requests. So this approach is more resource intensive. If no threads are available to process incoming request then the request has to wait in queue.
In this tutorial we will be implementing API Gateway using Spring Cloud Gateway. Spring Cloud Gateway is a non blocking API. When using non blocking API, a thread is always available to process the incoming request. These request are then processed asynchronously in the background and once completed the response is returned. So no incoming request never gets blocked when using Spring Cloud Gateway.

Posted Date:- 2021-09-24 05:51:25

How to achieve server side load balancing using Spring Cloud

Server side load balancingcan be achieved using Netflix Zuul.
Zuul is a JVM based router and server side load balancer by Netflix.
It provides a single entry to our system, which allows a browser, mobile app, or other user interface to consume services from multiple hosts without managing cross-origin resource sharing (CORS) and authentication for each one. We can integrate Zuul with other Netflix projects like Hystrix for fault tolerance and Eureka for service discovery, or use it to manage routing rules, filters, and load balancing across your system.

Posted Date:- 2021-09-24 05:50:51

What does one mean by Load Balancing ? How is it implemented in Spring Cloud

In computing, load balancing improves the distribution of workloads across multiple computing resources, such as computers, a computer cluster, network links, central processing units, or disk drives. Load balancing aims to optimize resource use, maximize throughput, minimize response time, and avoid overload of any single resource. Using multiple components with load balancing instead of a single component may increase reliability and availability through redundancy. Load balancing usually involves dedicated software or hardware, such as a multilayer switch or a Domain Name System server process.

Posted Date:- 2021-09-24 05:50:09

Give one/a few examples of microservices implementation.

Netflix, Paypal, Amazon, eBay, Twitter, and many other large-scale websites have started as monolithic and evolved into a microservices architecture.

Posted Date:- 2021-09-24 05:44:32

Where is the WebMVC Test Annotation used?

WebMvcTest Annotation is used for unit testing Spring MVC Applications, where the test objective is to focus on Spring MVC Components.

Ex: @WebMvcTest(value = ToTestController.class, secure = false)

In the above example, the intention is to launch the ToTestController. All other controllers and mappings will not be launched when this unit test is executed.

Posted Date:- 2021-09-24 05:44:08

What are the most common mistakes while transitioning to Microservices?

1. Failure to outline the main challenges.

2. I am rewriting already existing programs.

3. Vague definitions of responsibilities, timeline, and boundaries.

4. Failure to identify and implement automation.

Posted Date:- 2021-09-24 05:43:43

How do you create State Machines out of Microservices?

Each microservice owning its database is an independently deployable program. This enables the creation of State Machines by which we can specify different states and events for a particular microservice.

Posted Date:- 2021-09-24 05:42:49

How to achieve zero-downtime deployment(blue/green) when there is a database change?

The deployment scenario becomes complex when there are database changes during the upgrade. There can be two different scenarios: 1. database change is backward compatible (e.g. adding a new table column) 2. database change is not compatible with an older version of the application (e.g. renaming an existing table column)

* Backward compatible change: This scenario is easy to implement and can be fully automated using Flyway. We can add the script to create a new column and the script will be executed at the time of deployment. Now during blue/green deployment, two versions of the application (say v1 and v2) will be connected to the same database. We need to make sure that the newly added columns allow null values (btw that’s part of the backward compatible change). If everything goes well, then we can switch off the older version v1, else application v2 can be taken off.

* Non-compatible database change: This is a tricky scenario, and may require manual intervention in-case of rollback. Let's say we want to rename first_name column to fname in the database. Instead of directly renaming, we can create a new column fname and copy all existing values of first_name into fname column, keeping the first_name column as it is in the database. We can defer non-null checks on fname to post-deployment success. If the deployment goes successful, we need to migrate data written to first_name by v1 to the new column (fname) manually after bringing down the v1. If the deployment fails for v2, then we need to do the otherwise.
Complexity may be much more in a realistic production app, such discussions are beyond the scope of this book.

Posted Date:- 2021-09-24 05:41:56

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.

Posted Date:- 2021-09-24 05:38:10

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.

Posted Date:- 2021-09-24 05:37:45

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.

Posted Date:- 2021-09-24 05:37:18

How will you deploy Exception Handling in Microservices?

If an exception occurs while processing an HTTP request, you need to catch the exception in your controller or service and return an appropriate ResponseEntity manually. Here are some thumb rules for exception handling.

<> Add @ResponseStatus for exceptions that you write.
<> For all other exceptions, implement an @ExceptionHandler method on a @ControllerAdvice class or use an instance of SimpleMappingExceptionResolver.
<> For Controller specific exceptions, add @ExceptionHandler methods to your controller.

Point to be noted is that @ExceptionHandler methods on the controller are always selected before those on any @ControllerAdvice instance. It is undefined in what order ControllerAdvices are processed.

Posted Date:- 2021-09-24 05:36:35

What is Tasklet, and what is a Chunk?

The Tasklet is a simple interface with one method to execute. A tasklet can be used to perform single tasks like running queries, deleting files, etc. In Spring Batch, the tasklet is an interface that can be used to perform unique tasks like clean or set up resources before or after any step execution.

Posted Date:- 2021-09-24 05:35:48

What is Spring Batch Framework?

Spring Batch is an open-source framework for batch processing – execution of a series of jobs. Spring Batch provides classes and APIs to read/write resources, transaction management, job processing statistics, job restart, and partitioning techniques to process high volume data.

Posted Date:- 2021-09-24 05:35:27

When will you see fit to use the Netflix Hystrix?

Hystrix is an error tolerance and latency library. Hystrix mainly isolates the access points. It also makes sure that all 3rd Party libraries and services are restricted. Thus, we can use Hystrix to ensure that an application runs efficiently and avoids the kind of failures that occur in distributed systems.

Posted Date:- 2021-09-24 05:35:04

How will you balance the server-side load by utilizing Spring Cloud?

The server-side load balancing can be done by using Netflix Zuul. It is also known as a JVM based router.

Posted Date:- 2021-09-24 05:34:48

What are Reactive Extensions in Microservices?

Reactive Extensions is a design approach through which results are collected by calling multiple services in order to compile a combined response. Also known as Rx, these calls can be synchronous or asynchronous.

Posted Date:- 2021-09-24 05:34:27

What are the different types of credentials of a two-factor Authentication?

Two-factor authentication calls for a second round of authentication to an account login process. Entering a username – password is a one-factor authentication. Username – Password authentication and then say mobile number or a secret key authentication can be considered as a two - factor authentication.

The different types of credentials for two-factor authentication can be:

* Something you know - A PIN, password or a pattern
* Something you have – ID, ATM No., Phone No, or an OTP
* Something you are – Your Biometrics.

Posted Date:- 2021-09-24 05:34:01

What is Canary Releasing?

Canary releasing is a technique by which new software versions are introduced by rolling out the updated version to a small subset of users before rolling it out to the entire infrastructure and making it available to everybody. This technique is so-called because it is based on canary releases in coal mines to alert miners when the toxic gases reach dangerous levels.

Posted Date:- 2021-09-24 05:33:29

What is the difference between Mock & Stub?

A Mock is generally a dummy object where certain features are set into it initially. Its behavior mainly depends on these features, which are then tested.

A Stub is an object that helps in running the test. It functions in a fixed manner under certain conditions. This hard-coded behavior helps the stub to run the test.

Posted Date:- 2021-09-24 05:32:46

What can you derive/understand from Conway’s Law?

Melvin Conway stated this idea in the late 1960s. This law implies that ‘organizations which design systems are constrained to produce designs which are copies of the communication structures of these organizations.” In simpler words, the team of people who design a piece of software will eventually make the design as per their perspective.

Posted Date:- 2021-09-24 05:32:26

How will you Configure Spring Boot Application Login?

Spring Boot Application Login can be configured by specifying the logging.level in the application. Properties file. It is usually pre-configured as console output.

Posted Date:- 2021-09-24 05:31:52

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

Posted Date:- 2021-09-24 05:31:02

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.

Posted Date:- 2021-09-24 05:30:18

What are Cloud-Native applications?

Cloud-Native Applications (NCA) is a style of application development that encourages easy adoption of best practices in the area of continuous delivery and distributed software development. These applications are designed specifically for a cloud computing architecture (AWS, Azure, CloudFoundary, etc).

DevOps, continuous delivery, microservices, and containers are the key concepts in developing cloud-native applications.

Spring Boot, Spring Cloud, Docker, Jenkins, Git are a few tools that can help you write Cloud-Native Application without much effort.


It is an architectural approach for developing a distributed system as a collection of small services. Each service is responsible for a specific business capability, runs in its own process and communicates via HTTP REST API or messaging (AMQP).


It is a collaboration between software developers and IT operations with a goal of constantly delivering high-quality software as per customer needs.

Continuous Delivery

Its all about automated delivery of low-risk small changes to production, constantly. This makes it possible to collect feedback faster.


Containers (e.g. Docker) offer logical isolation to each microservices thereby eliminating the problem of "run on my machine" forever. It’s much faster and efficient compared to Virtual Machines.

Posted Date:- 2021-09-24 05:29:15

R4R Team
R4R provides Microservice Freshers questions and answers (Microservice Interview Questions and Answers) .The questions on R4R.in website is done by expert team! Mock Tests and Practice Papers for prepare yourself.. Mock Tests, Practice Papers,Micro-services interview questions for experienced,Microservice Freshers & Experienced Interview Questions and Answers,Microservice Objetive choice questions and answers,Microservice Multiple choice questions and answers,Microservice objective, Microservice questions , Microservice answers,Microservice MCQs questions and answers R4r provides Python,General knowledge(GK),Computer,PHP,SQL,Java,JSP,Android,CSS,Hibernate,Servlets,Spring etc Interview tips for Freshers and Experienced for Microservice fresher interview questions ,Microservice Experienced interview questions,Microservice fresher interview questions and answers ,Microservice Experienced interview questions and answers,tricky Microservice queries for interview pdf,complex Microservice for practice with answers,Microservice for practice with answers You can search job and get offer latters by studing r4r.in .learn in easy ways .