Just went to the interview, spring cloud asked me 35 questions, all shared!

Time:2021-1-27

For now, microservice is one of the skills that programmers must master. As a high-quality micro service framework, spring cloud has been used by many companies. The following small make-up for you to sort out 35 knowledge points of spring cloud, or the interview questions are not conflict. It will be updated in the future ⛽ ️

1. What is spring cloud?

Spring cloud provides developers with tools to quickly build some common patterns in distributed systems (for example, configuration management, service discovery, circuit breaker, intelligent routing, micro agent, control bus, one-time token, global lock, leader election, distributed session, cluster state). They can work in any distributed environment, including developers’ own laptops, bare metal data centers, cloud foundry and other hosting platforms.

2. What is micro service?

The so-called micro service is the final product of SOA architecture. The design goal of the architecture is to dismember the business and make the service run independently. Microservice design principles:

1. Each performs its own duties.

2. High availability and scalability of services.

3. What are the characteristics of spring cloud?

Spring cloud focuses on providing a good out of the box experience for typical use cases and extensibility mechanisms, including other use cases.

  • Distributed / versioned configuration
  • Service registration and discovery
  • route
  • Service to service invocation
  • load balancing
  • Circuit breaker
  • Global lock
  • Leadership election and cluster status
  • Distributed messaging

4. Spring cloud core components?

Eureka: Registry

Ribbon: customer service load balancing

Hystrix: service fault tolerance processing

Feign: declarative rest client

Zuul: service gateway

Config: distributed configuration

5. What protocol is spring cloud based on?

HTTP

6. What’s the difference between spring cloud and Dubbo?

Just went to the interview, spring cloud asked me 35 questions, all shared!

7. What is Eureka?

Cloud service discovery, a rest based service, is used to locate services, so as to realize cloud middle layer service discovery and fail over.

8. The basic role of service governance?

Service registry: the ability to provide service registration and discovery.

Service provider: an application that provides services will register its services with the registry.

Service consumer: the consumer of the service, obtaining the service list from the registration center.

9. What is service renewal?

After registering the service, the service provider will maintain a heartbeat to prove to the registry that it is still alive, so as to prevent it from being “excluded from the service”.

10. What is offline service?

When the service instance is shut down normally, it will send a rest request (I’m going offline) to the registry. After receiving the request, it will set the service status down and propagate the event.

11. What is failure elimination?

When the service is offline abnormally, the service registry may not receive the offline request. The registry will create a timed task (default 60s) to eliminate the service that has not been renewed within a fixed time (default 90s).

12. What is self-protection mechanism?

During the operation, the registry will count whether the heartbeat failure rate is less than 85% within 15 minutes. If it is less than 85%, the registry will protect the current registered instance information and will not delete the instance information. When the network is restored, it will exit the self-protection mechanism.

Self protection mechanism makes service cluster more stable and robust.

13. What is ribbon?

It provides cloud load balancing. There are many load balancing strategies to choose from, which can be used with service discovery and circuit breaker.

14. What is the comment of ribbon load balancing?

@LoadBalanced

15. What are the ribbon load balancing strategies?

Randomrule: random.

Round robin rule: polling.

Retryrule: try again.

Weightedresponsetimerule: weight.

Clientconfignenabledroundrobin rule: generally not used. By inheriting this policy, the default choice implements the linear polling mechanism. We can expand on it.

Best available rule: by facilitating all service instances maintained in the load balancer, it will filter out the failed ones and select the one with the smallest concurrent requests.

Predicatebasedrule: filter the list before polling.

Availability filtering rule: inherits the parent class’s filtering list before polling. The algorithm is adjusted.

Zoneavoidancerule: this class is also a subclass of predicatebasedrule, which can combine filtering conditions. Zone availability forecast is the main filter condition and availability forecast is the secondary filter condition.

16. What is service?

The function of service fusing is similar to that of our household fuse. When a service is unavailable or the response times out, in order to prevent the whole system from avalanche, we temporarily stop calling the service.

17. What is service degradation?

Service degradation refers to the strategic degradation of some services and pages according to the current business situation and traffic when the server pressure increases sharply, so as to release the server resources and ensure the normal operation of the core tasks.

18. What is hystrix?

Fuse, a fault-tolerant management tool, aims to control the nodes of service and third-party library through the fuse mechanism, so as to provide more powerful fault-tolerant capability for delay and fault.

19. What are the functions of the circuit breaker hystrix?

  • It provides protection and control for the system when the third-party clients access the dependent services with high delay or failure.
  • Prevent cascading failure (service avalanche effect) in complex distributed systems.
  • Failure fast can recover quickly at the same time.
  • Provide fallback and elegant service degradation mechanism.
  • Provide near real-time monitoring, alarm and operation and maintenance control means.

20. Hystrix encapsulates remote calls to?

In the hystrixcommand or hystrixobservablecommand object.

21. Notes for starting the service?

@EnableHystrix

22. What is feign?

Feign is a declarative and templated HTTP client.

23. What are the advantages of feign?

1. Feign uses interface based annotation.
2. Feign integrates ribbon and has the ability of load balancing.
3. Integrated hystrix, with fusing ability.

24. What is config?

Configuration management toolkit enables you to put configuration on remote servers and centrally manage cluster configuration. Currently, it supports local storage, GIT and subversion.

25. Two roles in the config component?

Config server: configuration center server.

Config client: configuration center client.

26. What is zuul?

Zuul is a framework that provides dynamic routing, monitoring, flexibility, security and other edge services on cloud platform. Zuul is equivalent to the front door of all requests from the back end of the web site of the device and Netflix streaming application.

27. What are the advantages of using zuul?

  • Easy to monitor. The data can be monitored in the micro service network management and pushed to the external system for analysis.
  • Convenient for authentication. The unified authentication can be carried out in the gateway, and then the in session request can be forwarded to the back-end service.
  • Hiding the implementation details of the architecture, providing a unified entry to the client request, reducing the interaction times between the client and each micro service.
  • It can deal with cross-sectional tasks in a unified way, avoid the self-development of each micro service, and improve efficiency.
  • High availability and high scalability services to avoid single point failure.

28. What is the core of zuul?

filter.

29. How many types of filters does zuul have? namely?

Four.

Pre: can be called before the request is routed.

It is applicable to the scenario of identity authentication. After the authentication is passed, the following process can be continued.

Route: called when routing a request.

It is suitable for grayscale publishing scene, and can do some custom logic when routing.

Post: called after the route and error filters.

This kind of filter will be executed after requests are routed to specific services. It is suitable for application scenarios such as adding response header and recording response log.

Error: called when an error occurred while processing the request.

When sending errors in the process of execution, it will enter the error filter, which can be used to record error information uniformly.

30. What is sleuth?

Log collection toolkit, which encapsulates dapper and log based tracing, Zipkin and htrace operations, implements a distributed tracing solution for spring cloud applications.

31. What did sleuth do to help us?

  • It is convenient to understand the time-consuming of each sampling request and analyze which service calls are time-consuming.
  • For the exception not caught by the program, you can see it on the integrated Zipkin service page.
  • Identify the services that are called frequently to optimize.

32. What is bus?

Event and message bus are used to propagate state changes in the cluster (for example, configuration change events). Hot deployment can be implemented jointly with spring cloud config.

33. What are the advantages of Eureka over zookeeper?

A: High availability C: consistency, P: partition fault tolerance

Zookeeper guarantees CP, Eureka guarantees AP.

Eureka can well deal with the situation that some nodes lose contact due to network failure, and will not paralyze the whole micro service like zookeeper.

34. What is stream?

Data stream operation development package encapsulates sending and receiving messages with redis, rabbit, Kafka, etc.

35. What other microservice frameworks do you know?

Dubbo Motan Tars gRPC Thrift

reference resources:
  • Spring cloud
  • Spring cloud microservice full stack technology and case analysis
  • Spring cloud microservice architecture development practice
  • ​ https://spring.io/projects/sp…
  • ​ https://www.springcloud.cc/
  • Baidu Encyclopedia

The article is continuously updated, ⛽ ️。 In addition, the blogger sorted out and created 150000 word interview questions, including 17 topics. Welcome to “Java show” and reply to “interview” to get interview notes of Java show.pdf

Recommended Today

Rust programming video tutorial (Advanced) – 024_ 3 syntax of all modes 3

Video address Headline address:https://www.ixigua.com/i677586170644791348…Station B address:https://www.bilibili.com/video/av81202308/ Source address GitHub address:https://github.com/anonymousGiga/learn_rus… Explanation content 1. Ignore values in mode(1) Use_ Ignore entire valueexample: fn foo(_: i32, y: i32) { println!(“This code only uses the y parameter: {}”, y); } fn main() { foo(3, 4); } Note: placeholders are used for parameters in the function, mainly when implementing […]