Skip to main content

Microservices


*********************Micro services  Interview Question***************************
1.      Question 1. What Are Microservices?
Answer :
Microservices is a variant of the service-oriented architecture (SOA) architectural style that structures an application as a collection of loosely coupled services. In a microservices architecture, services should be fine-grained and the protocols should be lightweight. The benefit of decomposing an application into different smaller services is that it improves modularity and makes the application easier to understand, develop and test. It also parallelism development by enabling small autonomous teams to develop, deploy and scale their respective services independently. It also allows the architecture of an individual service to emerge through continuous refactoring. Microservices-based architectures enable continuous delivery and deployment.
2.      Question 2. What Is Spring Cloud?
Answer :
Spring Cloud Stream App Starters are Spring Boot based Spring Integration applications that provide integration with external systems. Spring Cloud Task. A short-lived microservices framework to quickly build applications that perform finite amounts of data processing.
3.      Question 3. What Are The Advantages Of Using Spring Cloud?
Answer :
When developing distributed microservices with Spring Boot we face the following issues-
o    Complexity associated with distributed systems-
This overhead includes network issues, Latency overhead, Bandwidth issues, security issues.
o    Service Discovery-
Service discovery tools manage how processes and services in a cluster can find and talk to one another. It involves a directory of services, registering services in that directory, and then being able to lookup and connect to services in that directory.
o    Redundancy-
Redundancy issues in distributed systems.
o    Loadbalancing-
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.
o    Performance issues-
Performance issues due to various operational overheads.
o    Deployment complexities-
Requirement of Devops skills.
4.      Question 4. What Is A Microservices Architecture?
Answer :
Microservices architecture allows to avoid monolith application for large system. It provide loose coupling between collaborating processes which running independently in different environments with tight cohesion.
5.      Question 5. What Are The Advantages And Disadvantages Of Microservices?
Answer :
Microservices Advantages
o    Smaller code base is easy to maintain.
o    Easy to scale as individual component.
o    Technology diversity i.e. we can mix libraries, databases, frameworks etc.
o    Fault isolation i.e. a process failure should not bring whole system down.
o    Better support for smaller and parallel team.
o    Independent deployment
o    Deployment time reduce
Microservices Disadvantages
o    Difficult to achieve strong consistency across services
o    ACID transactions do not span multiple processes.
o    Distributed System so hard to debug and trace the issues
o    Greater need for end to end testing
o    Required cultural changes in across teams like Dev and Ops working together even in same team.
6.      Question 6. What Netflix Projects Did We Use?
Answer :
Eureka created by Netflix, it is the Netflix Service Discovery Server and Client. Netflix Ribbon, it provide several algorithm for Client-Side Load Balancing. Spring provide smart RestTemplate for service discovery and load balancing by using @LoadBalanced annotation with RestTemplate instance.
7.      Question 7. How Will You Monitor Multiple Microservices For Various Indicators Like Health?
Answer :
Spring Boot provides actuator endpoints to monitor metrics of individual microservices. These endpoints are very helpful for getting information about applications like if they are up, if their components like database etc are working good. But a major drawback or difficulty about using actuator enpoints is that we have to individually hit the enpoints for applications to know their status or health. Imagine microservices involving 50 applications, the admin will have to hit the actuator endpoints of all 50 applications. To help us deal with this situation, we will be using open source project located at Built on top of Spring Boot Actuator, it provides a web UI to enable us visualize the metrics of multiple applications.
8.      Question 8. What Does One Mean By Service Registration And Discovery ? How Is It Implemented In Spring Cloud?
Answer :
When we start a project, we usually have all the configurations in the properties file. As more and more services are developed and deployed, adding and modifying these properties become more complex. Some services might go down, while some the location might change. This manual changing of properties may create issues. Eureka Service Registration and Discovery helps in such scenarios. As all services are registered to the Eureka server and lookup done by calling the Eureka Server, any change in service locations need not be handled and is taken care of.
9.      Question 9. How Do You Setup Service Discovery?
Answer :
Spring Cloud support several ways to implement service discovery but for this I am going to use Eureka created by Netflix. Spring Cloud provide several annotation to make it use easy and hiding lots of complexity.
10.  Question 10. How Do You Access A Restful Microservice?
Answer :
o    Load Balanced RestTemplate.
o    If there are multiple RestTemplate you get the right one.
o    It can used to access multiple microservices.
11.  Question 11. How To Achieve Server Side Load Balancing Using Spring Cloud?
Answer :
Server side load balancing can be achieved using Netflix Zuul. Zuul is a JVM based router and server side load balancing 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.
12.  Question 12. What Is Eureka?
Answer :
Eureka is the Netflix Service Discovery Server and Client. Eureka Server is using Spring Cloud.


Comments

Post a Comment

Popular posts from this blog

Mockito interview Questions

1.       Question 1. What Is Mockito? Answer : Mockito allows creation of mock object for the purpose of Test Driven Development and Behavior Driven development. Unlike creating actual object, Mockito allows creation of fake object (external dependencies) which allows it to give consistent results to a given invocation. 2.       Question 2. Why Do We Need Mockito? What Are The Advantages? Answer : Mockito differentiates itself from the other testing framework by removing the expectation beforehand. So, by doing this, it reduces the coupling. Most of the testing framework works on the "expect-run-verify". Mockito allows it to make it "run-verify" framework. Mockito also provides annotation which allows to reduce the boilerplate code. 3.       Question 3. Can You Explain A Mockito Framework? Answer : In Mockito, you always check a particular class. The dependency in that class is injected using m...

JAVA Expert Interview Questions Answers 2017

Java Basics ::  Interview Questions and Answers Home  »  Interview Questions  »  Technical Interview  »  Java Basics  » Interview Questions 1.     What is the difference between a constructor and a method? A constructor is a member function of a class that is used to create objects of that class. It has the same name as the class itself, has no return type, and is invoked using the new operator. A method is an ordinary member function of a class. It has its own name, a return type (which may be void), and is invoked using the dot operator. 2.     What is the purpose of garbage collection in Java, and when is it used? The purpose of garbage collection is to identify and discard objects that are no longer needed by a program so that their resources can be reclaimed and reused. A Java object is subject to garbage collection when it becomes unreachable to the program in which it is used. 3.  ...

Java Example Program to Convert List to Set

import java.util.ArrayList; import java.util.HashSet; import java.util.Set; public class ListToSet {  /**   * @author Amarjit Kumar   * @category interview questions   *   * Description: Convert List to set in java with example program   *   */  public static void main(String[] args) {   ArrayList<String> arrList= new ArrayList<>();   arrList.add("Java");   arrList.add("Java");   arrList.add("List to String");   arrList.add("Example Program");   Set<String> strSet = new HashSet<String>(arrList);   System.out.println(strSet);   System.out.println(arrList);  } } /*  * Java program to convert list to set. Convert ArrayList of string to HashSet  * in java example program How to convert List to Set in java Set<String> strSet  * = new HashSet<String>(arrList); HashSet having a constructor which will take  * list as an ar...