You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<strong>A lightweight dynamic thread pool based on configuration centers, with built-in monitoring & alerting, middleware thread pool management, and SPI extensibility</strong>
protectedvoid beforeExecute(Thread t, Runnable r); // before task execution
63
+
protectedvoid afterExecute(Runnable r, Throwable t); // after task execution
61
64
```
62
65
63
66
</details>
64
67
65
-
现在大多数的互联网项目都会采用微服务化部署,有一套自己的服务治理体系,微服务组件中的分布式配置中心
66
-
扮演的就是动态修改配置,实时生效的角色。
68
+
Most modern internet projects adopt microservice architecture with a service governance stack. The distributed configuration center plays a key role — enabling real-time configuration changes with instant effect.
67
69
68
-
那么我们是否可以结合配置中心来做运行时线程池参数的动态调整呢?
70
+
So, can we combine a configuration center to dynamically adjust thread pool parameters at runtime?
Absolutely. Configuration centers are highly available, relieving concerns about config push failures and reducing the effort of building a dynamic thread pool solution from scratch.
-**Ubiquity**: Thread pools are a fundamental tool used by 90%+ of Java developers to improve system performance.
75
77
76
-
-**不确定性**:项目中可能存在很多线程池,既有 IO 密集型的,也有 CPU 密集型的,但线程池的核心参数并不好确定,需要有套机制在运行过程中动态去调整参数
78
+
-**Uncertainty**: Projects often contain many thread pools — some IO-intensive, some CPU-intensive — and optimal core parameters are hard to determine upfront, requiring runtime tuning.
-**Lack of visibility**: Thread pool metrics are invisible during operation. A monitoring & alerting mechanism is needed to detect issues before and during incidents.
-**High availability**: Configuration changes must be reliably pushed to clients. Leveraging an existing configuration center greatly improves system availability.
Based on the above analysis, we extended `ThreadPoolExecutor` with the following goals:
87
89
88
-
> 1.实现对运行中线程池参数的动态修改,实时生效
90
+
> 1.Dynamic parameter modification at runtime, taking effect instantly.
89
91
>
90
-
> 2.实时监控线程池的运行状态,触发设置的报警策略时报警,报警信息推送办公平台
92
+
> 2.Real-time monitoring of thread pool status with alerting, pushing notifications to office platforms.
91
93
>
92
-
> 3.定时采集线程池指标数据,配合像 Grafana 这种可视化监控平台做大盘监控
94
+
> 3.Periodic metric collection, integrated with visualization platforms like Grafana for dashboards.
93
95
>
94
-
> 4.集成常用三方中间件内部线程池管理
96
+
> 4.Thread pool management for commonly used third-party middleware.
95
97
96
-
**经过多个版本的迭代,目前最新版本 v1.2.2 具有以下特性** ✅
98
+
**Latest version features:** ✅
97
99
98
-
-**代码零侵入**:我们改变了线程池以往的使用姿势,所有配置均放在配置中心,服务启动时会从配置中心拉取配置生成线程池对象放到 Spring 容器中,使用时直接从 Spring 容器中获取,对业务代码零侵入
100
+
-**Zero code intrusion**: All configuration lives in the configuration center. At startup, thread pools are created from config and registered in the Spring container — inject and use directly, zero impact on business code.
-**Multiple pool modes**: `DtpExecutor` (enhanced), `EagerDtpExecutor` (IO-intensive), `ScheduledDtpExecutor` (scheduled), `OrderedDtpExecutor` (ordered). Choose based on your scenario.
113
115
114
-
-**兼容性**:JUC 普通线程池和 Spring 中的 ThreadPoolTaskExecutor 也可以被框架管理,只需@Bean 定义时加 @DynamicTp 注解即可
116
+
-**Compatibility**: Standard JUC thread pools and Spring `ThreadPoolTaskExecutor` can be managed by adding `@DynamicTp` on the `@Bean` definition.
115
117
116
-
-**可靠性**:依靠 Spring 生命周期管理,可以做到优雅关闭线程池,在 Spring 容器关闭前尽可能多的处理队列中的任务
118
+
-**Graceful shutdown**: Leverages Spring lifecycle management to shut down thread pools gracefully, processing as many queued tasks as possible before shutdown.
-**Battle-tested at scale**: Inspired by [Meituan's thread pool practice](https://tech.meituan.com/2020/04/02/java-pooling-pratice-in-meituan.html), with mature production experience at Meituan.
121
123
122
124
---
123
125
124
-
## 架构设计
126
+
## Architecture
125
127
126
-
**框架功能大体可以分为以下几个模块**
128
+
**The framework is divided into the following modules:**
-Alert notifications are pushed when thresholds are triggered (thread activity, queue capacity, rejection, task wait/execution timeout), with highlighted fields.
> 📖 See the official documentation for details: [Alerting](https://dynamictp.cn/guide/notice/alarm.html)| [Monitoring](https://dynamictp.cn/guide/monitor/collect_types.html)
-[HertzBeat](https://github.com/dromara/hertzbeat): An easy-to-use, real-time monitoring and alerting system with powerful custom monitoring capabilities, no Agent required.
0 commit comments