preface

Recently in view of the Internet company interview asked knowledge points, summed up the Java programmer interview involves most of the interview questions and answers to share with you, I hope to help you review before the interview and find a good job, but also save you on the Internet to search for information time to learn.

Content covers: Java, MyBatis, ZooKeeper, Dubbo, Elasticsearch, Memcached, Redis, MySQL, Spring, SpringBoot, SpringCloud, RabbitMQ, Kafka, Linux and other technology stacks.

Full version Java interview questions address: Java backend questions integration

1. What is Spring Cloud?

The Spring Cloud Streaming application launcher is a Spring integration application based on Spring Boot that provides integration with external systems.

Spring Cloud Task, a microservices framework with a short life span, is used to quickly build applications that perform limited data processing.

2. What are the advantages of using Spring Cloud?

When developing distributed micro-services using Spring Boot, we face the following issues

(1) Complexity associated with distributed systems – this overhead includes network issues, latency costs, bandwidth issues, and security issues.

(2) Service discovery – The service discovery tool manages how processes and services in the cluster look up and talk to each other.

It involves a catalog of services in which you can register services and then be able to find and connect to services in that catalog.

(3) redundancy – the redundancy problem in distributed system.

(4) Load balancing — Load balancing improves the distribution of workloads across multiple computing resources, such as computers, computer clusters, network links, central processing units, or disk drives.

(5) Performance – Issues Performance issues due to various operational overhead.

(6) Deployment complexity -Devops skill requirements.

3. What does service registration and discovery mean? How is Spring Cloud implemented?

When we start a project, we usually do all the configuration in the properties file.

As more services are developed and deployed, adding and modifying these properties becomes more complex.

Some services may decline and some locations may change. Manually changing properties can cause problems.

Eureka service registration and discovery can help in this situation.

Because all services are registered on the Eureka server and lookup is done by calling the Eureka server, there is no need to handle any changes and processing of the service location.

4. What is the significance of load balancing?

In computing, load balancing can improve workload distribution across multiple computing resources such as computers, computer clusters, network links, central processing units, or disk drives.

Load balancing is designed to optimize resource usage, maximize throughput, minimize response time, and avoid overloading any single resource.

Load balancing with multiple components rather than a single component may improve reliability and availability through redundancy.

Load balancing typically involves proprietary software or hardware, such as multi-tier switches or domain name system server processes.

5. What is Hystrix? How does it achieve fault tolerance?

Hystrix is a delay and fault tolerant library designed to isolate access points to remote systems, services and third party libraries, stopping cascading failures when failures are unavoidable and enabling resilience in complex distributed systems.

Typically for systems developed using a microservice architecture, many microservices are involved.

These microservices work with each other. Consider the following microservices

Suppose that if microservice 9 in the figure above fails, we will propagate an exception using traditional methods.

But it can still cause the whole system to crash. The problem becomes more complicated as the number of microservices increases.

The number of microservices can be as high as 1000. This is where Hystrix comes in and we will use hystrix’s Fallback method functionality in this case.

We have two services employee-Consumer that use services exposed by Employee-Consumer.

The simplified figure is shown below

Now suppose that for some reason the employee-producer exposed service throws an exception.

We defined a fallback method in this case using Hystrix.

This backup method should have the same return type as the exposed service.

If an exception occurs in the exposed service, the fallback method returns some values.

6. What is Hystrix circuit breaker? Do we need it?

For some reason, the Employee-Consumer exposure service throws an exception.

Using Hystrix in this case we define a fallback method.

If an exception occurs in the exposed service, the fallback method returns some default values.

If the exception in firstPage Method () continues, the Hystrix circuit will break and the employee users will collectively skip the firtsPage method and call the fallback method directly.

The purpose of a circuit breaker is to allow time for the first page method or other methods that the first page method might call and cause an abnormal recovery.

What may happen is that, with a low load, the problem that caused the exception has a better chance of recovery.

7. What is Netflix Feign? What are its advantages?

Feign is a Java client interprogramming inspired by Retrofit, JAXRS-2.0, and WebSocket.

Feign’s first goal was to unify the complexity of the constraint denominator into the HTTP apis, regardless of its stability.

In the Employee-consumer example, we use the Employee-Producer REST service exposed using the REST template.

But we have to write a lot of code to perform the following steps

(1) Use functional zones for load balancing.

(2) Get the service instance, and then get the base URL.

8. What is Spring Cloud Bus? Do we need it?

Consider the following situation: we have multiple applications that use Spring Cloud Config to read properties, and Spring Cloud Config reads those properties from GIT.

The following example shows multiple Employee producer modules fetching Eureka registered properties from the Employee Config Module.

What happens if you assume that the Eureka registration property in GIT changes to point to another Eureka server.

In this case, we would have to restart the service to get the updated properties.

There is another way to use executor endpoints/flushes.

But we will have to call this URL separately for each module.

For example, if Employee Producer1 is deployed on port 8080, http:// localhost: 8080 / refresh is called.

Also for Employee Producer2 http://localhost8081 / refresh, etc. That’s a hassle.

This is where Spring Cloud Bus comes in.

Spring Cloud Bus provides the ability to refresh configurations across multiple instances.

Therefore, in the example above, if we refresh Employee Producer1, all other required modules are automatically refreshed.

This is especially useful if we have multiple microservices up and running.

This is achieved by connecting all microservices to a single message broker.

Whenever an instance is refreshed, this event subscribes to all microservices listening to this agent, and they are refreshed as well.

The refresh of any single instance can be achieved by using endpoint/bus/refresh.

Full version Java interview questions address: Java backend questions integration