10 interviewers like to ask the micro-services face questions Spring Cloud + Spring Boot

Preface
Why use micro service?
With the rapid development of the Internet, businesses are using the Internet. The Internet has shaped the people can not be separated form ×××. As more and more users, and more and more complex business scenarios.
Traditional single architecture has been difficult to meet the requirements of development of Internet technology, the code readability and maintainability, scalability, reduce, increase maintenance costs are driving the development trend of micro-services.
10 interviewers like to ask the micro-services face questions Spring Cloud + Spring Boot

Which micro-services framework

Dubbo, Alibaba's core service governance framework, and is widely used in various member stations Alibaba Group
points. Contributions to the open source community Alibaba in recent years both at home and abroad are compelling, such as:
JStorm donated to the Apache and joined the Apache Foundation for the China Internet competing with enough of the face, making the A
Alibaba in people eyes has been upgraded from electricity suppliers is a technology company up.
Spring Cloud, from the name we can know that it is a product of Spring Source, a strong community of Spring
big endorsement is arguably the most influential business organization Java, in addition to Spring Source, there are
Pivotal and its Netfix strong backing and technical output. Which open source Netflix's entire suite of micro-services architecture is
the core of Spring Cloud.

Talk about the realization of the principle of RPC

First you need to have a network connection module handles communications, responsible for connection establishment, management and transmission of messages. Second, the need for coding
decoding module, network communications are transmitted as bytecode, we use an object's serialization and deserialization
of. The rest is the client and the server-side portion of the server-side exposed to the open service interface, customer service calls
a proxy service that implements the interface, the proxy implementation is responsible for collecting data, encoded and transmitted to the server and then wait for the results
to return.

Talk about the realization of the principle of Dubbo

dubbo as rpc framework, the effect achieved is to call a remote method just like a local call. How to do
it? Is the local to the remote methods are described, including the method name, parameters, return values, and are present in the remote dubbo are
to use the same interface; then, must be packaged for network communication, to be communicated for caller details is completely
visible, the communication network to do is to call the method through a certain property protocol (message format is simply
the formula) is transmitted to the server; server protocol in accordance with analysis information of the call; the respective method; in the process will return
back to the value passed to the client by a protocol; re-parsing the client; call on the call mode can be divided into synchronous and asynchronous transfer
used; simply on this basic process
10 interviewers like to ask the micro-services face questions Spring Cloud + Spring Boot

What are the advantages Spring Boot there?

Spring Boot 的优点有:
减少开发,测试时间和努力。
使用 JavaConfig 有助于避免使用 XML。
避免大量的 Maven 导入和各种版本冲突。
提供意见发展方法。
通过提供默认值快速开始开发。
没有单独的 Web 服务器需要。这意味着你不再需要启动 Tomcat,Glassfish 或其他任何东
西。
需要更少的配置 因为没有 web.xml 文件。只需添加用@ Configuration 注释的类,然后添加
用@Bean 注释的方法,Spring 将自动加载对象并像以前一样对其进行管理。您甚至可以将
@Autowired 添加到 bean 方法中,以使 Spring 自动装入需要的依赖关系中。
基于环境的配置 使用这些属性,您可以将您正在使用的环境传递到应用程序:-
Dspring.profiles.active = {enviornment}。在加载主应用程序属性文件后,Spring 将在
(application{environment} .properties)中加载后续的应用程序属性文件。
如何实现 Spring Boot 应用程序的安全性?
为了实现 Spring Boot 的安全性,我们使用 spring-boot-starter-security 依赖项,并且必须添
加安全配置。它只需要很少的代码。配置类将必须扩展 WebSecurityConfigurerAdapter 并覆
盖其方法。
如何集成 Spring Boot 和 ActiveMQ?
对于集成 Spring Boot 和 ActiveMQ,我们使用
spring-boot-starter-activemq
依赖关系。 它只需要很少的配置,并且不需要样板代码。
什么是 Swagger?你用 Spring Boot 实现了它吗?
Swagger 广泛用于可视化 API,使用 Swagger UI 为前端开发人员提供在线沙箱。Swagger 是
用于生成 RESTful Web 服务的可视化表示的工具,规范和完整框架实现。它使文档能够以
与服务器相同的速度更新。当通过 Swagger 正确定义时,消费者可以使用最少量的实现逻
辑来理解远程服务并与其进行交互。因此,Swagger 消除了调用服务时的猜测。
10 interviewers like to ask the micro-services face questions Spring Cloud + Spring Boot

使用 Spring Cloud 有什么优势?

使用 Spring Boot 开发分布式微服务时,我们面临以下问题
与分布式系统相关的复杂性-这种开销包括网络问题,延迟开销,带宽问题,安全问题。
服务发现-服务发现工具管理群集中的流程和服务如何查找和互相交谈。它涉及一个服务目录,在该目录中注册服务,然后能够查找并连接到该目录中的服务。
冗余-分布式系统中的冗余问题。
负载平衡 --负载平衡改善跨多个计算资源的工作负荷,诸如计算机,计算机集群,网络链路,中央处理单元,或磁盘驱动器的分布。
性能-问题 由于各种运营开销导致的性能问题。
部署复杂性-Devops 技能的要求。

负载平衡的意义什么?

In computing, load balancing can improve computer across a variety of computing computer cluster, network links, central processing unit or disk drives
workload distribution of resources. Load balancing to optimize resource utilization, maximize throughput, minimize response time and avoid any single resource
overload. A plurality of load balancing components rather than a single component may be used to improve the reliability and availability through redundancy. Load balancing often involves special software or hardware, such as multi-layer switch or domain name system server process.
What is Netflix Feign? What advantage is that?
Feign is subject Retrofit, JAXRS-2.0 and WebSocket inspired java client binder. Feign's first goal
is to unify the denominator of the complexity of the constraints to http apis, regardless of its stability. In the case of employee-consumer, we
use the employee-producer templates using REST REST public service.
But we have to write a lot of code to perform the following steps
use the ribbon for load balancing.
Examples of access to services, and access to basic URL.
Use templates to use REST service. The preceding code is as follows

@Controller
public class ConsumerControllerClient {

@Autowired
private LoadBalancerClient loadBalancer;

public void getEmployee() throws RestClientException, IOException {

ServiceInstance serviceInstance=loadBalancer.choose("employee-producer");

 System.out.println(serviceInstance.getUri());

 String baseUrl=serviceInstance.getUri().toString();

 baseUrl=baseUrl+"/employee";

RestTemplate restTemplate = new RestTemplate();
 ResponseEntity<String> response=null;
try{
 response=restTemplate.exchange(baseUrl,
 HttpMethod.GET, getHeaders(),String.class);
}catch (Exception ex)
 {
 System.out.println(ex);
}
 System.out.println(response.getBody());
}

Before code, there are exceptions such as NullPointer opportunity, not optimal. We will see how to use Netflix Feign make calls easier and cleaner. If Netflix Ribbon class path dependencies are, then Feign default will be responsible for load balancing.

I remember the article points like a praise, thanks for the support!

Guess you like

Origin blog.51cto.com/14442094/2423433