Spring Microservices Interview Questions

What is Micro Services Architecture, how is it different from Monolithic Architecture?

  • Monolithic is good for small team.It can be moved easily.
  • Monolithic is faster,as we do not have much netowrk call
  • Team has to understand everything.
  • Deployment is difficult.
  • When one system crashes , others also will not work.

A micro Service consists of a single business unit , all data and and functions which are relevant are put into a service.It is more about separating concerns or work of every service. They can have theor own dataabse and own servcies.Client talks to gateway and they in return gateways connect to micro services. We can do parallel Development in Micro Services.

Notes on MicroServices:

Advantages of Microservices:
  • New Technology and Process adoption, each microservices can be built in different technology.
  • Dynamic scaling based on load, which helps reduce infra cost.
  • Faster release cycle. 

Complexities in MicroServices Architecture:
  • Service Discovery
  • Metric Collection
  • Orchestration
  • Network
  • API Management
Microservices Architecture: Netflix OSS
SideCar design Pattern: Sidecar Handles all incoming and outgoing Traffic
Every service will have a sidecar which will be centrally controlled by Control Panel

Few important aspects of microservices:
Naming Server (Eureka)
Ribbon(Client Load Balancing)
Feign(Easier REST client)
Zipkin Distributed Tracing
Netflix API gateway
Fault Tolerance: Hystrix
Spring Cloud Sleuth

What is liveness and readiness in MicroServices?

The liveness state of an application says whether the application's internal state is valid.
The Readiness state tells whether the application is ready to accept client requests.
Below is some official documentation on same.

liveness-and-readiness Spring blog
K8s Article on same

How to microservices authenticate with each other?

What is Tracing and how do you do tracing in Micro Services?

There are a wide verity of solution for centralized logging like elk stack, log stack and Kibana. Which uses elastic search to search for it. Spring has Zipkin distributed tracing server.

What is Feign?

Feign provides easy steps for communicating between Micro Services.

What is the use of Netflix Ribbon Client?

It is used mostly with Feign service and used for load balancing.
In feign we can configure only one instance of a service. Whereas in Ribbon we can configure multiple instances through application.properties file as a list.

What is Naming Server and what is the use of it?

The challenge with Ribbon client is we need to change the properties file for new services, which is not acceptable in a production environment, so the naming server helps us dynamically handle it.
The two main use of Naming Server is Service Registry and Service Discovery.
In Spring boot we use Netflix Eureka Naming Server.

What is 12 Factor architecture in Micro Services?

  1. CodeBase :
  2. One codebase per service, tracked in revision control;
  3. Dependancies :
  4. Explicitly declare and isolate dependencies. Handle it using Docker.
  5. Config :
  6. Store configuration in the environment
  7. Backing Services:
  8. Treat backing services as attached resources
  9. Build, Release, Run
  10. Strictly separate build and run stages.Using CI/CD tool to automate build.
  11. Process :
  12. Execute the app in one or more stateless processes.
  13. Data Isolation :
  14. Each service manages its own data.
  15. Concurrency :
  16. Scale out via the process model.
  17. Disposability :
  18. Maximize robustness with fast startup and graceful shutdown
  19. Dev/Prod Parity :
  20. Keep development, staging, and production as similar as possible
  21. Logs:
  22. Treat logs as event streams
  23. Admin Processes :
  24. Run admin and maintainance task separately from the process.

      What is API Gateway

      API Gateway is commonplace for interaction, of microservices and other functionalities like

      • Authentication
      • Rate Limits
      • Fault Tolerance
      • Service Aggregation

      In Spring we use Zuul as an API Gateway for microServices.

Previous
Next Post »

Pages