1.whitch types of protocol does dubbo support?
dubbo (Binary Serialization ) Hessian、 RESTful、 HTTP
2.what is multicast?
- config priorities from high to low:
method level,interface level,default/global level,
at the same level , consumer has higher pro than provider
5 . dubbo.properties
dubbo.properties
will be loaded by dubbo aotomatically
and it can be used with dubbo’s annotations
- the Priority of configuration decreasing from top to bottom is
system propeties -Ddubboxxx
extern config eg:Apollo,
SPring xml/API
Local file dubbo.properties
7.the reason why dubbo add REST into itself is to make itself service-oriented and easy to be used by non-dubbo consumers
8 架构演进过程
9. dubbo fault tolerance strategy
failover 故障自动转移 自动尝试其他server <dubbo:service retries=“2” /> usually used for read operation
failfast 只调用一次 通常用于非幂等接口 == failover+retries=0
failsafe 不抛出异常,用于记录日志等
failback 后台重试转发,一般用于消息通知操作发短信等
forking 同时调用多个服务,一个返回则成功,用于实时读取场景
broadcast 广播 调用所有服务 ,一般用于更新服务的日志或者配置等 an exception will be throwed when all nodes are invoked unsuccessfully
一般系统常见容错机制:failover ,failsafe,failfase ,failback,forking,来源于阿里的定义。
10. loadbalance strategy
Ramdom the larger the amount of the calls,the more uniform the distrbutions
roundrobin use weight to determine round ratio
LeastActive slower providers will receive less requests
consistenthash the requests with same parameters will be sent to the same provider
配置优先级 同级别 reference>service
11 Thread Model
1I/O thread will be used directly if event can be handled qualicky like marking in the memory
2. use thread pool if it takes a while to handle events. Otherwise io thread wont receive more requests
3 dispatcher
all :all messages will be dispatched to thread pool
direct: all messages will be handled by io thread(the workers of netty)
message: only request and response messages will be dispatched to thread pool
execution: only request oessage willl be dispatched to thread pool
connection: connection messages will be executed by io thread and other message will be dispathed to the therad pool
thread pool
fixed (default) ,cached(automatically created when needed and destroy when in idel for one minute),limit(elatically increased but not decreased)
P2P connection used in test and devepment environment based on api not method
@DubboReference(check = false,methods = {@Method(name = “sayHi”,loadbalance = “consistenthash”)},url = “dubbo://localhost:20881”)
if port 20881 is down, consumer wont switch to other providers
191config ‘register=false’ to subscribe only for test
12 multiple protocols
dubbo supports multiple protocols in an application
big data may use short connection protocol while small data and concurrent should use long connection protocol
2dubbo support multiple registries at the same time
13group
used to distinguish different impls when we have multi-imps of an interface
14 version
used to compatible the upgrad of interface
15 validate
16 cache
dubbo support lru , threadlocal and cache extension
same input means same output and dubbo does not send the request with same input twice when using cache
17 echo service
used to test the service`s availability
all services implement EchoService automatically
18 Context
RpcContext is a temporary status recorder of ThreadLocal, When executing rpc call ,it will be changed
for example ,A->B->C,for B it records the information about A->B befor B->c and keeps a record of information about b-c after b->c
note: RpcContext will be changed after Rpc call everytime
19 Async call
config async=true to make a call asyncally and get the future from RpcContext.getContext()
20 Aync execute
like servlet 3.0 it will reduce mutual influence between requests
21 event notify
on return ,on throw and on invoke
the first parameter is the returned Object followed by the input parameters sequencely in notified method ,otherwise rpc may invoke onThrow method if it is set up
22 Local Mock
used for service downgrade
23 concurrency
control the concurrency of a specified method of a specified service
(1) config “executes” (at service level or a method level) at service side to control concurrency of a method at service side
(2) config “actives” to control the number of concurrent excutions at consumer-side
24 protocol
(1)dubbo protocol
this is suitable for small data and high concurrency because of single(can be configed) and long connection
in other word,its not for transporting big data like files
parameters have to impement Serializable Interface
if data scale is large, maybe we can add to the “connections”
(2)http protocol
based on HTTP form and spring httpInvoker
have multiple and short connection
used for both app and brower
(3)redis protocol
(4)rest protocol
based on http and rest
(5)webservice protocol
(6)rmi protocol
using jdk rmi ,have multiple connection and can be used to transfer files
25 registry
(0) registry can be regard as an approach to store services info
(1)zookeeper
all services info is put into node /dubbo
(2) redis
the way of k-v to store the services info
(3)multiple
(4)simple
use a simple dubbo service
- qos quality of service
(1)used to manage services for example offline but not shutdown a provider serivce
(2) interacted by telnet or http
(3)command
ls offline xxx online xxx help, use help to see all
(4) offline command unregister the service from registry while online command register it again
best practice
(1) try catch and parameter validation are better on providers side
(2) version should be configed
(3) attributes of consumer side should bu configed on provider side as much as possible
eg: loadbalance,execute
(4)filecache
used when registry is down
路由转发
在上线完成之后,先让一小部分的调用请求进行逻辑验证,待没问题后再接入其他的服务节点,从而实现流量隔离的效果,
在负载均衡之前 通过路由规则增加个筛选功能强行圈定一个合适的服务范围,然后再在改范围内负载
负载均衡
,往往对应着一个集群。当请求到来的时候,为了将请求均衡的负载到合适的服务器,负载均衡程序将通过相应的规则,选取一台服务器进行访问,这个过程被称为负载均衡。而这些服务器提供的服务是相同的
dubbo支持
condition路由
标签路由
标签路由通过将某一个或多个服务的提供者划分到同一个分组,约束流量只在指定分组中流转,从而实现流量隔离的目的,可以作为蓝绿发布、灰度发布等场景的能力基础
dubbo中通过这个实现tagstateRouter,主要是根据tag和生产端的tag做比对,比成功或者tag为空的provider会被返回
pom
<dubbo.version>3.0.10</dubbo.version>
<spring-boot.version>2.7.1</spring-boot.version>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-dependencies-bom</artifactId>
<version>${dubbo.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>${spring-boot.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring-boot.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
<version>${dubbo.version}</version>
<exclusions>
<exclusion>
<groupId>com.alibaba.spring</groupId>
<artifactId>spring-context-support</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>${protobuf-java.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-client</artifactId>
<version>${nacos.version}</version>
<exclusions>
<exclusion>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.alibaba.spring</groupId>
<artifactId>spring-context-support</artifactId>
<version>${alibaba.spring-context-support.version}</version>
</dependency>