Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the SpringCloud-related interview questions?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "what are the SpringCloud-related interview questions". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn what are the SpringCloud-related interview questions.

I. Overview of micro-services

1. What are the advantages and disadvantages of microservices? Tell me about the pit encountered in the development project?

Advantages:

(1) each service is directly enough cohesive and the code is easy to understand.

(2) the development efficiency is high, and a service only does one thing, which is suitable for small team development.

(3) loosely coupled, functional services.

(4) it can be developed in different languages and interface-oriented programming.

(5) easy for third-party integration.

(6) Micro services are just business logic code and will not be combined with HTML,CSS or other interfaces.

(7) it can be flexibly matched to connect common libraries / independent libraries.

Disadvantages:

(1) the responsibility of distributed system

(2) it is more difficult for multi-service operation and maintenance.

(3) system deployment dependence, inter-service communication cost, data consistency, system integration testing, performance monitoring.

2. What is springcloud?

The Spring cloud streaming Application launcher is a Spring Boot-based Spring integration application that provides integration with external systems. Spring cloud Task, a short-lived micro-service framework for quickly building applications that perform limited data processing

3. The difference between spring cloud and dubbo?

(1) the service invocation method dubbo is RPC springcloud Rest Api

(2) Registration center, dubbo is zookeeper springcloud, it is eureka, it can also be zookeeper

(3) Service gateway, dubbo itself is not implemented, can only be integrated through other third-party technologies, springcloud has Zuul routing gateway, as a routing server for consumer request distribution, springcloud supports circuit breakers, perfectly integrated with git configuration files support version control, transaction bus to achieve configuration file update and service automatic assembly and so on a series of micro-service architecture elements.

4. Comparison between REST and RPC

(1) the main drawback of RPC is that the dependence between the service provider and the invocation method is too strong. It is necessary to define the interface of each micro-service, and through continuous inheritance and release, strict version control will not conflict.

(2) REST is a lightweight interface, there is no code coupling between service provision and invocation, only a convention is needed to standardize it.

5. What kind of micro-service technology stack do you know?

(1) Service development: springboot spring springmvc

(2) Service configuration and management: Archaiusm of Netfix, Diamond of Ali

(3) Service registration and discovery: Eureka,Zookeeper

(4) Service call: Rest RPC gRpc

(5) Service fuse: Hystrix

(6) Service load balancer: Ribbon Nginx

(7) Service API call: Fegin

(8) message queue: Kafka Rabbitmq activemq

(9) Service configuration center management: SpringCloudConfig

(10) Service routing (API Gateway) Zuul

(11) event message bus: SpringCloud Bus

6. What is the meaning of load balancing?

In computing, load balancing can improve the workload distribution across a variety of computing resources, such as computers, computer clusters, network links, central processing units or disk drives. Load balancing is designed to optimize resource usage, maximum throughput, minimum response time, and avoid overloading any single resource. Using multiple components for load balancing rather than a single component may improve reliability and availability through redundancy. Load balancing usually involves specialized software or hardware, such as multilayer switches or domain name system service processes.

7. How do microservices communicate independently?

(1) remote calls, such as feign calls, are directly called by remote procedures to access other service.

(2) message middleware

8. Why use microservices?

(1) with the rapid development of the Internet, various industries are using the Internet. The Internet has been inseparable from all kinds of people. With more and more users, the business scenario becomes more and more complex.

(2) the traditional single architecture has been difficult to meet the requirements of the development of Internet technology, the reduction of code maintainability scalability and readability, and the increase of maintenance costs are the development trend of driving micro-services.

II. Overview of SpringCloud

1. How does springcloud implement the registration of services?

(1) when the service is published, specify the corresponding service name and register the service with the registry (eureka zookeeper)

(2) add @ EnableEurekaServer to the registry, use @ EnableDiscoveryClient for the service, and then use ribbon or feign for direct service call discovery.

2. The difference between Eureka and Zookeeper

(1) Eureka takes the AP of CAP and pays attention to usability, while Zookeeper takes CP of CAP.

Consistency.

(2) the Zookeeper registration service was paralyzed during the election period, and although the service will eventually be restored, it will not be available during the election period.

(3) one result of eureka's self-protection mechanism is that services that have expired because they have not received a heartbeat for a long time will not be removed from the registration list. Registration and query requests for new services can still be accepted, but will not be synchronized to other nodes. The service will not be paralyzed.

(4) Zookeeper has the roles of Leader and Follower, and all nodes of Eureka are equal.

(5) Zookeeper adopts the principle of more than half survival, and Eureka adopts self-protection mechanism to solve the zoning problem.

(6) eureka is essentially a project, and Zookeeper is just a process.

3. What is the self-protection mechanism of eureka?

When the Eureka Server node loses the connection of too many instances in a short time (such as network failure or frequent startup and shutdown of the client), the node will enter the self-protection mode, protect the registration information, no longer delete the registration data, and automatically exit the self-protection mode when the failure recovers.

4. What is a service breaker? What is a service downgrade?

Direct calls to services, such as process blocking in the case of high concurrency, cause the current thread to be unavailable, slowly blocking all threads, and causing the server to avalanche.

Service fuse: equivalent to a fuse, when an exception occurs, the entire service is directly disconnected instead of waiting for the service to time out.

Service degradation: by maintaining its own thread pool, the service degradation is started when the thread reaches the threshold, and the default value of fallback is returned directly if other requests continue to access.

5. What is Ribbon?

Ribbon is a load balancing client, which can well control some behaviors of http and tcp. Feign integrates ribbon by default.

6. What is feigin? What are its advantages?

(1) feign uses interface-based annotations

(2) feign integrates ribbon and has the ability of load balancing.

(3) integrate Hystrix and have the ability of fusing.

Use:

(1) add pom dependency.

(2) add @ EnableFeignClients to the startup class

(3) define an interface @ FeignClient (name= "xxx") to specify which service to invoke

7. What's the difference between Ribbon and Feign?

(1) Ribbon invokes other services, but in different ways.

(2) Startup class annotations are different. Ribbon is @ RibbonClient, and feign is @ EnableFeignClients.

(3) the location specified by the service is different. Ribbon is declared on the @ RibbonClient annotation, while Feign uses @ FeignClient declaration in the interface that defines abstract methods.

(4) the calling method is different. Ribbon needs to build the http request by itself, simulate the http request and then send it to other services using RestTemplate. The steps are quite tedious. Feign needs to define the called method as an abstract method.

8. The function of springcloud circuit breaker?

When one service invokes another service due to network reasons or its own reasons, the caller will wait for the callee's response when more service requests to these resources lead to more requests waiting, resulting in a knock-on effect (avalanche effect)

The circuit breaker is fully open: it cannot be called for a certain number of times over a period of time and monitors several times that the circuit breaker is fully open with no signs of recovery so that the service will not be requested for the next request.

Half open: there are signs of recovery in a short period of time, the circuit breaker will send part of the request to the service, and the circuit breaker will shut down when it is called normally.

Shutdown: when the service has been in a normal state, it can be called normally

9. What is Spring Cloud Bus?

Spring cloud bus connects distributed nodes with lightweight message agents, which can be used to broadcast changes to configuration files or communicate directly with services, as well as for monitoring. If the configuration file is modified and a request is sent, all clients will reread the configuration file.

Use:

(1) add dependencies

(2) configure rabbimq

10. What is SpringCloudConfig?

In the distributed system, due to the large number of services, in order to facilitate the unified management of service configuration files and real-time update, distributed configuration center components are needed. In Spring Cloud, there is a distributed configuration center component, spring cloud config, which allows configuration services to be placed in memory (that is, locally) of configuration services, as well as in remote Git repositories. In the spring cloud config component, there are two roles, one is config server, and the other is config client.

Use:

(1) add pom dependency

(2) add relevant configurations to the configuration file

(3) add annotation @ EnableConfigServer to the startup class

11 、 Spring Cloud Gateway?

Spring Cloud Gateway is the second generation gateway framework officially launched by Spring Cloud, replacing the Zuul gateway. As a kind of traffic, gateway plays a very important role in micro-service system. The common functions of gateway are routing and forwarding, authority verification, current limiting control and so on.

Use a RouteLocatorBuilder bean to create a route, in addition to creating a route RouteLocatorBuilder allows you to add a variety of predicates and filters,predicates assertions, as the name implies, according to the specific request rules, by the specific route to deal with, filters is a variety of filters, used to make various judgments and modifications to the request.

12. What is Hystrix?

Avalanche prevention weapon, with service degradation, service breaker, dependency isolation, monitoring (Hystrix Dashboard) service degradation:

The Singles' Day hint: Oh, hey, it's crowded. App has deserted on the Internet. Please try again later.

Priority core services, non-core services are not available or weakly available. The HystrixCommand annotation specifies. The degradation logic is implemented in fallbackMethod (fallback function).

At this point, I believe you have a deeper understanding of "what are the SpringCloud-related interview questions?" you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report