Home > Back-end >  SpringCloud interview questions and answers
SpringCloud interview questions and answers

Time:12-03

North Pole: https://www.cnblogs.com/aishangJava/p/11927311.html
1. What is the spring cloud?
Spring cloud is a series of an ordered set of framework, which makes use of the development of spring boot convenience cleverly simplifies the distributed system for the development of infrastructure, such as registration service discovery, configuration center, message bus, load balancing, circuit breaker, data monitoring, etc., can use spring development style of boot accomplish a key to start and deploy,

2. The spring cloud what is the function of a circuit breaker?
In a distributed architecture, the circuit breaker model role is also similar, when a service unit fails (similar to use electrical short-circuit), through the circuit breaker failure monitoring (similar to blow out the fuse), returned to the caller an error response, rather than waiting for a long period of time, so as not to make a thread for fault service call is occupied by a long time not to release, to avoid the spread of fault in the distributed system,

3. The spring cloud core components have?
Eureka: service registered in found that

Feign: based on the dynamic proxy mechanism, according to the comments and select machine, joining together the request url address, initiate the request,

Ribbon: load balancing, from a service on one of the many machines,

Hystrix: provide the thread pool, different service take different thread pool, implements the isolation of different service calls, to avoid the problem of the service avalanche,

Zuul: gateway management, by Zuul gateway to forward the request to the corresponding service,

4. SpringCloud and Dubbo
SpringCloud and Dubbo are now mainstream micro service architecture
SpringCloud is Apache's Spring under the system of micro service solutions
Dubbo distributed service governance framework is ali department
From the technical dimensions, actually SpringCloud far exceed the Dubbo, Dubbo itself only implement the service management, and SpringCloud now and after 21 project will more
So many people would say that Dubbo and SpringCloud is unfair
But due to reasons such as RPC and metadata registry, at the time of technology selection, we can only choose between them, so we often use them to compare
Service invocation style Dubbo using the RPC remote invocation, and SpringCloud is using a Rest API, in fact more in line with the definition of micro service official
Service registry, Dubbo use third-party ZooKeeper as its underlying registry, the implementation of the service registration and discovery, SpringCloud using Spring Cloud Netflix Eureka registry, SpringCloud, of course, also can use a ZooKeeper implementation, but usually we don't do this
Service gateway, Dubbo does not itself implement, only by other third-party technology integration, and SpringCloud has Zuul routing gateway, routing server, as to the request of the consumer distribution, SpringCloud also supports the circuit breaker, and git perfect integrated distributed configuration file support version control, transaction bus to realize automatic updating and service configuration file assembly and so on a series of micro service architecture elements

Tell from the selected technology ~

At present domestic is still mainly distributed system selection Dubbo, after all, domestic and domestic engineers skilled degree is high, and Dubbo flaws in other dimensions can be offset by other third-party framework to integrate
SpringCloud is now more popular abroad, of course, I think the domestic market will slowly towards SpringCloud, even liujun as head of Dubbo restart published point of view, is the development direction of Dubbo actively adapt SpringCloud ecology, not clashed

Rest and RPC contrast

If read micro service participant Martin fowler's thesis can find the definition of communication mechanism between service is Http Rest
RPC is the main defect between service provider and invoke methods rely on too strong, we need for each micro service interface definition, and through continuous inheritance issue, need strict version control won't appear between services and call conflicts because of different version
And the REST is lightweight interface, the provision of services and call there is no coupling between the code, just specification through a convention, but there are also possible documentation and inconsistent interface due to the service integration problems, but it can be through integration of swagger tools, code and documentation is integration solution, so the REST in a distributed environment more flexible than RPC
This is why dangdang DubboX in enhancement of Dubbo increased support for the REST of the reason

Document quality and community activity

SpringCloud community activity is far higher than that of Dubbo, from beam team, after all, the reason lead to Dubbo stop updating iteration for five years, the small and medium-sized companies cannot afford to technology development costs lead to Dubbo community seriously depressed, and SpringCloud boom, micro service quickly occupied the market, back to the Spring mix of popular
Dubbo very mature after many years of accumulation of documents, for micro service companies also have the architecture of the system stable status quo

5. SpringBoot and SpringCloud
SpringBoot Spring is introduced to solve the traditional framework configuration file redundancy, multifarious solutions based on Maven assembly components, designed to quickly build a single micro service
While SpringCloud focus on solving the coordination between the various micro service and configuration, communication between services, fusing, load balance, etc.
Technical dimensions and the same, and is dependent on SpringBoot SpringCloud, while SpringBoot is not dependent on SpringCloud, can even and excellent integrated development Dubbo

Conclusion:

SpringBoot focus on the most convenient and fast development of the individual service

SpringCloud is to focus on the global micro service coordination governance framework, integrate and manage all the services, to provide various micro between services, configuration management, service discovery, circuit breaker, bus route, events and other integrated services

SpringBoot does not depend on SpringCloud, rely on SpringBoot SpringCloud, belongs to the dependencies

SpringBoot focus on quick, convenient and the development of a single individual services, SpringCloud focus on global service governance framework

6. The service is how to separate the communication between the
1. The Remote Procedure call (Remote Procedure Invocation) :

Namely we often say service registration and discovery of

Directly through the remote procedure call (RPC) to access any other service,

Advantages:

Simple, common, because without the middleware proxy, the system more simple

Disadvantages:

Only support the request/response mode, does not support the other, such as notification, asynchronous request/response, publish/subscribe, publish/asynchronous response

Reduced the availability, because the client and the server must be available in the process of request

2. Message:

Using asynchronous message for communication between services, services through messages between pipeline to exchange messages, thus communication,

Advantages:

The client and the server decoupling, more loosely coupled

Improve availability, because the message middleware caches, until consumers can consume

Support many communication mechanisms such as notification, asynchronous request/response, publish/subscribe, publish/asynchronous response

Disadvantages:

Message middleware has extra complex

7. What is the meaning of load balancing?
In calculation, load balancing can improve across computers, computer cluster, network link, and the central processing unit or disk drives, and other computing resources work load distribution, load balancing is designed to optimize resource usage, the maximum throughput and minimum response time and avoid any single resource overload, the use of multiple components to load balance rather than a single component may through redundancy to improve reliability and availability, load balancing usually involves proprietary software or hardware and multilayer switches or domain name system service process, for example,

8. Springcloud how to implement the service registration?
1. The service is released, specifies the corresponding service, the service registry to the registry (eureka zookeeper)
2. Add @ EnableEurekaServer registry, service use @ EnableDiscoveryClient, then with a ribbon or feign found directly call for service,

9. What is the service fusing? What is the service down
In the complicated distributed system, the interaction between the micro service calls, may appear all sorts of reasons lead to the blocking of the service, the high concurrency scenarios, the blocking of the service means that the thread blocking, causes the current thread is not available, the server thread blocked, cause server crash, because the relationship between the invocation of the service are synchronous, can cause the service to the whole service system avalanche

In order to solve a micro service invocation response time is too long or is not available to take up more and more system resources is needed to cause an avalanche effect the fusing and downgrade the service processing,

Fusing the so-called service refers to a service failure or abnormal a similar display the "fuse" when an abnormal condition in the world is trigger fusing the entire service directly, rather than wait until the service timeout,

Service fuse is equivalent to our switch fuse, in the event of service avalanche, will fuse the whole service, by maintaining an own thread pool, when a thread to start the service degradation threshold, if other requests continue to access it directly back to fallback default

10. What are the advantages and disadvantages of micro service? Say you met in the project development under pit
Advantages of

Each service enough cohesion, the code easier to understand

Development efficiency, do one thing a service

Micro service can be a small team development alone

Services are loosely coupled, is a functional significance of service

Can use different language development, programming to an interface

Easy to integrate with a third party

Micro service business logic code only, won't and HTML, CSS, or other interface combination

Development, the two development modes
Front end separation
The whole stack engineer

Can be connected to public libraries/connection flexible collocation, independent library

Disadvantages

Distributed system is responsible for the sex

Service operations more difficult, with the increase of service, the operational pressure increases

System deployment depend on

Communication cost between service

Data consistency

The systems integration test

Performance monitoring

11. You know micro service technology stack?
Dimension (springcloud)
Service development: springboot spring for springmvc
Configuration and management of service: netflix Archaiusm, ali's Diamond
Service registration and discovery: Eureka, Zookeeper
Service invocation: Rest RPC gRpc
Services: fuse Hystrix
Service load balancing: Ribbon Nginx
The service interface call: Fegin
Message queue: Kafka Rabbitmq activemq
Service center of configuration management: SpringCloudConfig
Zuul service routing gateway (API)
Event message Bus: SpringCloud Bus
12. Eureka and they can all provide service registration and discovery of the function, please tell me the differences between the two
1. They guarantee is CP, had guaranteed the AP

ZooKeeper registration service paralyzed during the election, although the service will eventually recover, but is not available during the period of election

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related