10+ Must Read Java Microservice Interview Questions

In this article, we will discuss some of the frequently asked Microservice interview questions and answers.

  1. What is a Microservice ?
  2. Explain Microservice architecture
  3. What is a Gateway in microservice ?
  4. Which tools you use for automation in microservice environments ?
  5. What is Spring Boot? Why is Spring Boot popular for Java microservice development ?
  6. What are advantages of using Microservices over traditional monolithic architecture?
  7. What is CI/CD ?
  8. What is Spring Cloud ?
  9. How do you monitor microservices?
  10. What is Kubernetes ?
  11. How do you manage logging with Microservices ?
  12. How to build Fault tolerant microservices ?
  13. What is a Reverse Proxy ?

For microservice interview questions specific to Spring Boot, refer the following post :
Spring Boot Interview Questions

Q 1: What is a Microservice ?


Microservice is an architectural style that structures an application as a collection of self contained, loosely coupled services.

We can create microservices in several languages including Java, Scala, Node.js etc.

Here are some of the similarities of Microservice(MS) with SOA services :

– Microservices are loosely coupled and interact with each other through json, xml etc
– They are reusable and can be accessed through desktop application, web applications, mobile applications and even be called by other microservices.
– WADL, JSON Schema or Swagger are mostly used for describing the microservices.

Here are some ways MS are different:

– There is no physical infrastructre dependencies with microservices. They are usually deployed in Docker containers which encapsulate both the code and required libraries.
– Microservices don’t relay on enterprise products like ESB.

Q 2 : Explain Microservice architecture


Microservice architecture consists of small, independent, self-contained services that implement a single functionality.
microservice interview questions

Ref : https://docs.microsoft.com/en-us/azure/architecture/guide/architecture-styles/microservices

Client : The Client could be a desktop or mobile client or even another microservice.

API Gateway : It handles client requests and forwards to the appropriate service.

Service : Small, independent, loosely coupled microservices.

Service Discovery : Enables service lookup to find the endpoint for a service.


Q 3: What is a Gateway in microservice ?


Clients do not directly invoke microservices, they go through the Gateway. The Gateway in turn calls the microservices and returns the response to the client.

The Gateway decouples the microservices from the clients. It also provides functions like authentication, logging, load balancing etc.


Q 4 : Which tools you use for automation in microservice environments ?


Microservices are automated starting from development till deployment to production.

GIT is mostly used for version control
Jenkins is used for continuous integration
– Testing tools like JUnit, Selenium are used for automating testing.
– Container technologies like Docker are used with release management tools like Chef or Puppet for infrastructure management automation.
– Deployment automation is done using tools such as Kubernetes or Spring Cloud.


Q 5 : What is Spring Boot? Why is Spring Boot popular for Java microservice development ?


Spring boot provides a lot of boiler plate code and configurations that we were manually doing for application development.
It abstracts the maven dependencies, configurations, application server and reduces development time.


Q 6 : What are advantages of using Microservices over traditional monolithic architecture?


Microservices-based architectures enable continuous delivery and deployment.

Microservices are smaller in size and can be quickly built & delivered. This is a great fit in Agile development as the business users don’t have to wait to see the product.

In Microservice architecture, the individual services can be built in different language like Java, Scala. Also, different microservices could be on different versions of the same language like Java 8 & 9.

Microservices are independent, therefore one microservice can be independently scaled up or down independent of other microservices.
For example, if in Airline ticketing company, the ratio between flight ticket searches and bookings is 50:1, then the search microservice can be scaled up without impacting the ticket booking microservice.This brings down the cost as the company doesn’t have to scale the whole application to meet the performance needs.

With microservices, we can easily change the technology or version of individual services rather than having to affect the whole product.

Microservices are automation friendly and the changes can be continuously integrated with DevOps to increase speed of delivery.


Q 7 : What is CI/CD ?


Continuous Integration(CI) is the practice of automatically building and unit testing an entire application frequently, ideally on every source code check-in.

Continuous Delivery(CD) is the practice of deploying every build to a production like environment and performing automated integration and acceptance testing after it passes its build and unit tests.

This is required so that errors are identified at an early state and little to no coordination is required etween different teams building different microservices.

Q 8: What is 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).
Ref : http://projects.spring.io/spring-cloud/

Q 9: How do you monitor microservices?


Spring Boot actuator is a good tool monitor metrics, counters for individual microservices. But if you have multiple microservices, its difficult to monitor each individually.

For this, we can use open source tools like Prometheous, Kibana or Graphana.

Prometheous is a pull based monitoring tool. It contains metrics at given intervals, displays them and can also trigger alerts.

Kibana or Grafana are dashboard tools used to visualize and monitor the data.

When there are large number of microservices with dependencies, we can use AppDynamics, Dynatrace, and New Relic that can draw dependencies among microservices.


Q 10: What is Kubernetes ?


Kubernetes is the market leading orchestration solution.

It helps with automating container deployments, scheduling, and the scalability of containers.

Kubernetes supports features such as automatic progressive rollouts, versioned deployments, and container resiliency if containers fail due to some reason.


Q 11: How do you manage logging with Microservices ?


With microservices, we should avoid storing or routing the log files by the application itself.

The solution is to centrally store and analyze all log messages. In this approach, log messages are shipped from execution environments to a central big data store.

As part of centralized logging solution, several Cloud logging services like Loggly, Google Cloud Logging are available.

We can also use popular commercial logging solutions like Splunk for log management & analysis.


Q 12: How do you build Fault tolerant microservices ?


We could use Hystrix for this. Hystrix is a Fault & latency tolerance library designed by Netflix.
Hystrix is based on the fail fast and rapid recovery principles.

Usually for systems developed using Microservices architecture, there are many microservices involved. These microservices collaborate with each other.
If there is an issue with a service, Hystrix helps isolate it. It helps to recover quickly by falling back to another preconfigured fallback service.


Q 13: What is a Reverse Proxy ?


Reverse proxy retrieves resources from one or more services on behalf of the client.

Common uses for a reverse proxy server include:

– Load balancing
– Security


Q 14: What is Cohesion ?


Cohesion is the degree to which elements inside a module/service belong together.

Microservices should be highly cohesive in nature.

Q 15: What is Coupling and how microservices should be coupled?


Coupling is the degree of interdependence between software modules. It is a measure of how closely connected two routines or modules are.

Microservices should be loosely coupled with each other.

Q 16: What is an Actuator?


Actuator is used in Spring Boot to monitor the state of a microservice.
Spring Boot actuators provide restful service end points that can be used to check the various metrices.

Q 17: What is difference between REST & Microservice?


Microservice is an architectural style that structures an application as a collection of self contained, loosely coupled services.
RESTful services is a way to implement microservices.

Q 18: What is bounded context?


A bounded context can be thought of a logical boundary.

A Bounded Context encapsulates the details of a single domain, such as domain model, data model, application services, etc., and defines the integration points with other bounded contexts/domains.

Q 18: What is DRY principle in microservices?


DRY stands for Don’t Repeat Yourself.
It promotes code reusability


© 2018, https:. All rights reserved. On republishing this post, you must provide link to original post

Leave a Reply.. code can be added in <code> </code> tags