校园网网站建设费用如何申请网站空间
- 作者: 五速梦信息网
- 时间: 2026年04月20日 07:09
当前位置: 首页 > news >正文
校园网网站建设费用,如何申请网站空间,做网站要什么软件,怎么用电脑做网站服务器消费端线程模型#xff0c;提供者端线程模型 消费端线程模型 对 2.7.5 版本之前的 Dubbo 应用#xff0c;尤其是一些消费端应用#xff0c;当面临需要消费大量服务且并发数比较大的大流量场景时#xff08;典型如网关类场景#xff09;#xff0c;经常会出现消费端线程…消费端线程模型提供者端线程模型 消费端线程模型 对 2.7.5 版本之前的 Dubbo 应用尤其是一些消费端应用当面临需要消费大量服务且并发数比较大的大流量场景时典型如网关类场景经常会出现消费端线程数分配过多的问题具体问题讨论可参见 Need a limited Threadpool in consumer side #2013 改进后的消费端线程池模型通过复用业务端被阻塞的线程很好的解决了这个问题。 老的线程池模型 我们重点关注 Consumer 部分 业务线程发出请求拿到一个 Future 实例。业务线程紧接着调用 future.get 阻塞等待业务结果返回。当业务数据返回后交由独立的 Consumer 端线程池进行反序列化等处理并调用 future.set 将反序列化后的业务结果置回。业务线程拿到结果直接返回 当前线程池模型 提供端线程模型 Dubbo协议的和Triple协议目前的线程模型还并没有对齐下面分开介绍Triple协议和Dubbo协议的线程模型。 Dubbo协议 介绍Dubbo协议的Provider端线程模型之前先介绍Dubbo对channel上的操作抽象成了五种行为 建立连接connected主要是的职责是在channel记录read、write的时间以及处理建立连接后的回调逻辑比如dubbo支持在断开后自定义回调的hookonconnect即在该操作中执行。断开连接disconnected主要是的职责是在channel移除read、write的时间以及处理端开连接后的回调逻辑比如dubbo支持在断开后自定义回调的hookondisconnect即在该操作中执行。发送消息sent包括发送请求和发送响应。记录write的时间。接收消息received包括接收请求和接收响应。记录read的时间。异常捕获caught用于处理在channel上发生的各类异常。 Dubbo框架的线程模型与以上这五种行为息息相关Dubbo协议Provider线程模型可以分为五类也就是AllDispatcher、DirectDispatcher、MessageOnlyDispatcher、ExecutionDispatcher、ConnectionOrderedDispatcher。 配置方式 线程模型配置值All DispatcherallDirect DispatcherdirectExecution DispatcherexecutionMessage Only DispatchermessageConnection Ordered Dispatcherconnection 拿 application.yaml 的配置方式举例在protocol下配置dispatcher: all即可把dubbo协议的线程模型调整为All Dispatcher dubbo:application:name: dubbo-springboot-demo-providerprotocol:name: dubboport: -1dispatcher: allregistry:id: zk-registryaddress: zookeeper://127.0.0.1:2181 All Dispatcher 下图是All Dispatcher的线程模型说明图 在IO线程中执行的操作有 sent操作在IO线程上执行。序列化响应在IO线程上执行。在Dubbo线程中执行的操作有 received、connected、disconnected、caught都是在Dubbo线程上执行的。反序列化请求的行为在Dubbo中做的。 Direct Dispatcher 下图是Direct Dispatcher的线程模型说明图 在IO线程中执行的操作有 received、connected、disconnected、caught、sent操作在IO线程上执行。反序列化请求和序列化响应在IO线程上执行。 并没有在Dubbo线程操作的行为。 Execution Dispatcher 下图是Execution Dispatcher的线程模型说明图 在IO线程中执行的操作有 sent、connected、disconnected、caught操作在IO线程上执行。序列化响应在IO线程上执行。在Dubbo线程中执行的操作有 received都是在Dubbo线程上执行的。反序列化请求的行为在Dubbo中做的。 Message Only Dispatcher 在Provider端Message Only Dispatcher和Execution Dispatcher的线程模型是一致的所以下图和Execution Dispatcher的图一致区别在Consumer端。见下方Consumer端的线程模型。 下图是Message Only Dispatcher的线程模型说明图 在IO线程中执行的操作有 sent、connected、disconnected、caught操作在IO线程上执行。序列化响应在IO线程上执行。在Dubbo线程中执行的操作有 received都是在Dubbo线程上执行的。反序列化请求的行为在Dubbo中做的。 Connection Ordered Dispatcher 下图是Connection Ordered Dispatcher的线程模型说明图 在IO线程中执行的操作有 sent操作在IO线程上执行。序列化响应在IO线程上执行。在Dubbo线程中执行的操作有 received、connected、disconnected、caught都是在Dubbo线程上执行的。但是connected和disconnected两个行为是与其他两个行为通过线程池隔离开的。并且在Dubbo connected thread pool中提供了链接限制、告警灯能力。反序列化请求的行为在Dubbo中做的。 Triple协议 下图为Triple协议 Provider端的线程模型 Triple协议Provider线程模型目前还比较简单目前序列化和反序列化操作都在Dubbo线程上工作而IO线程并没有承载这些工作。 线程池隔离 一种新的线程池管理方式使得提供者应用内各个服务的线程池隔离开来互相独立某个服务的线程池资源耗尽不会影响其他正常服务。支持线程池可配置化由用户手动指定。 使用线程池隔离来确保 Dubbo 用于调用远程方法的线程与微服务用于执行其任务的线程是分开的。可以通过防止线程阻塞或相互竞争来帮助提高系统的性能和稳定性。 目前可以以 API、XML、Annotation 的方式进行配置 配置参数 ApplicationConfig 新增 String executor-management-mode 参数配置值为 default 和 isolation 默认为 default。 executor-management-mode default 使用原有 以协议端口为粒度、服务间共享 的线程池管理方式executor-management-mode isolation 使用新增的 以服务三元组为粒度、服务间隔离 的线程池管理方式ServiceConfig 新增 Executor executor 参数用以服务间隔离的线程池可以由用户配置化、提供自己想要的线程池若没有指定则会根据协议配置(ProtocolConfig)信息构建默认的线程池用以服务隔离。 ServiceConfig 新增 Executor executor 配置参数只有指定executor-management-mode isolation 才生效。 API public void test() {// provider appDubboBootstrap providerBootstrap DubboBootstrap.newInstance();ServiceConfig serviceConfig1 new ServiceConfig();serviceConfig1.setInterface(DemoService.class);serviceConfig1.setRef(new DemoServiceImpl());serviceConfig1.setVersion(version1);// set executor1 for serviceConfig1, max threads is 10NamedThreadFactory threadFactory1 new NamedThreadFactory(DemoService-executor);ExecutorService executor1 Executors.newFixedThreadPool(10, threadFactory1);serviceConfig1.setExecutor(executor1);ServiceConfig serviceConfig2 new ServiceConfig();serviceConfig2.setInterface(HelloService.class);serviceConfig2.setRef(new HelloServiceImpl());serviceConfig2.setVersion(version2);// set executor2 for serviceConfig2, max threads is 100NamedThreadFactory threadFactory2 new NamedThreadFactory(HelloService-executor);ExecutorService executor2 Executors.newFixedThreadPool(100, threadFactory2);serviceConfig2.setExecutor(executor2);ServiceConfig serviceConfig3 new ServiceConfig();serviceConfig3.setInterface(HelloService.class);serviceConfig3.setRef(new HelloServiceImpl());serviceConfig3.setVersion(version3);// Because executor is not set for serviceConfig3, the default executor of serviceConfig3 is built using// the threadpool parameter of the protocolConfig ( FixedThreadpool , max threads is 200)serviceConfig3.setExecutor(null);// It takes effect only if [executor-management-modeisolation] is configuredApplicationConfig applicationConfig new ApplicationConfig(provider-app);applicationConfig.setExecutorManagementMode(isolation);providerBootstrap.application(applicationConfig).registry(registryConfig)// export with tri and dubbo protocol.protocol(new ProtocolConfig(tri, 20001)).protocol(new ProtocolConfig(dubbo, 20002)).service(serviceConfig1).service(serviceConfig2).service(serviceConfig3);providerBootstrap.start();} XML beans xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlns:dubbohttp://dubbo.apache.org/schema/dubboxmlnshttp://www.springframework.org/schema/beansxsi:schemaLocationhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsdhttp://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd!– NOTE: we need config executor-management-modeisolation –dubbo:application namedemo-provider executor-management-modeisolation/dubbo:applicationdubbo:config-center addresszookeeper://127.0.0.1:2181/dubbo:metadata-report addresszookeeper://127.0.0.1:2181/dubbo:registry idregistry1 addresszookeeper://127.0.0.1:2181?registry-typeservice/dubbo:protocol namedubbo port-1/dubbo:protocol nametri port-1/!– expose three service with dubbo and tri protocol–bean iddemoServiceV1 classorg.apache.dubbo.config.spring.impl.DemoServiceImpl/bean idhelloServiceV2 classorg.apache.dubbo.config.spring.impl.HelloServiceImpl/bean idhelloServiceV3 classorg.apache.dubbo.config.spring.impl.HelloServiceImpl/!– customized thread pool –bean idexecutor-demo-serviceclassorg.apache.dubbo.config.spring.isolation.spring.support.DemoServiceExecutor/bean idexecutor-hello-serviceclassorg.apache.dubbo.config.spring.isolation.spring.support.HelloServiceExecutor/!– this service use [executorexecutor-demo-service] as isolated thread pool–dubbo:service executorexecutor-demo-serviceinterfaceorg.apache.dubbo.config.spring.api.DemoService version1.0.0 groupGroup1timeout3000 refdemoServiceV1 registryregistry1 protocoldubbo,tri/!– this service use [executorexecutor-hello-service] as isolated thread pool–dubbo:service executorexecutor-hello-serviceinterfaceorg.apache.dubbo.config.spring.api.HelloService version2.0.0 groupGroup2timeout5000 refhelloServiceV2 registryregistry1 protocoldubbo,tri/!– not set executor for this service, the default executor built using threadpool parameter of the protocolConfig –dubbo:service interfaceorg.apache.dubbo.config.spring.api.HelloService version3.0.0 groupGroup3timeout5000 refhelloServiceV3 registryregistry1 protocoldubbo,tri//beansAnnotation Configuration EnableDubbo(scanBasePackages org.apache.dubbo.config.spring.isolation.spring.annotation.provider) public class ProviderConfiguration {Beanpublic RegistryConfig registryConfig() {RegistryConfig registryConfig new RegistryConfig();registryConfig.setAddress(zookeeper://127.0.0.1:2181);return registryConfig;}// NOTE: we need config executor-management-modeisolationBeanpublic ApplicationConfig applicationConfig() {ApplicationConfig applicationConfig new ApplicationConfig(provider-app);applicationConfig.setExecutorManagementMode(isolation);return applicationConfig;}// expose services with dubbo protocolBeanpublic ProtocolConfig dubbo() {ProtocolConfig protocolConfig new ProtocolConfig(dubbo);return protocolConfig;}// expose services with tri protocolBeanpublic ProtocolConfig tri() {ProtocolConfig protocolConfig new ProtocolConfig(tri);return protocolConfig;}// customized thread poolBean(executor-demo-service)public Executor demoServiceExecutor() {return new DemoServiceExecutor();}// customized thread poolBean(executor-hello-service)public Executor helloServiceExecutor() {return new HelloServiceExecutor();} }// customized thread pool public class DemoServiceExecutor extends ThreadPoolExecutor {public DemoServiceExecutor() {super(10, 10, 60, TimeUnit.SECONDS, new LinkedBlockingDeque(),new NamedThreadFactory(DemoServiceExecutor));} }// customized thread pool public class HelloServiceExecutor extends ThreadPoolExecutor {public HelloServiceExecutor() {super(100, 100, 60, TimeUnit.SECONDS, new LinkedBlockingDeque(),new NamedThreadFactory(HelloServiceExecutor));} }// executor-hello-service is beanName DubboService(executor executor-demo-service, version 1.0.0, group Group1) public class DemoServiceImplV1 implements DemoService {Overridepublic String sayName(String name) {return server name;}Overridepublic Box getBox() {return null;} }// not set executor for this service, the default executor built using threadpool parameter of the protocolConfig DubboService(version 3.0.0, group Group3) public class HelloServiceImplV2 implements HelloService {private static final Logger logger LoggerFactory.getLogger(HelloServiceImplV2.class);Overridepublic String sayHello(String name) {return server hello;} }DubboService(executor executor-hello-service, version 2.0.0, group Group2) public class HelloServiceImplV3 implements HelloService {private static final Logger logger LoggerFactory.getLogger(HelloServiceImplV3.class);Overridepublic String sayHello(String name) {return server hello;} }线程池状态导出 dubbo 通过 Jstack 自动导出线程堆栈来保留现场方便排查问题。 默认策略 导出路径: user.home标识的用户主目录导出间隔: 最短间隔允许每隔10分钟导出一次导出开关: 默认打开 当业务线程池满时我们需要知道线程都在等待哪些资源、条件以找到系统的瓶颈点或异常点。 导出开关控制
dubbo.properties
dubbo.application.dump.enabletruedubbo:application namedemo-provider dump-enablefalse/dubbo:application:name: dubbo-springboot-demo-providerdump-enable: false导出路径
dubbo.properties
dubbo.application.dump.directory/tmpdubbo:application namedemo-provider dump-directory/tmp/dubbo:application:name: dubbo-springboot-demo-providerdump-directory: /tmp
- 上一篇: 校园设计网站用PS做网站搜索框
- 下一篇: 校园网网站建设规划书做的网站适应屏幕大小
相关文章
-
校园设计网站用PS做网站搜索框
校园设计网站用PS做网站搜索框
- 技术栈
- 2026年04月20日
-
校园内部网站平台建设方案开发网站网络公司有哪些
校园内部网站平台建设方案开发网站网络公司有哪些
- 技术栈
- 2026年04月20日
-
校园内部网站建设方案表白网页在线生成网站源码
校园内部网站建设方案表白网页在线生成网站源码
- 技术栈
- 2026年04月20日
-
校园网网站建设规划书做的网站适应屏幕大小
校园网网站建设规划书做的网站适应屏幕大小
- 技术栈
- 2026年04月20日
-
校园网站集群建设做网站找哪家又便宜又好
校园网站集群建设做网站找哪家又便宜又好
- 技术栈
- 2026年04月20日
-
校园网站建设 德育wordpress 添加menu
校园网站建设 德育wordpress 添加menu
- 技术栈
- 2026年04月20日






