Skip to content

Commit b5ae5c3

Browse files
committed
Set English README as default
1 parent 42fe847 commit b5ae5c3

3 files changed

Lines changed: 329 additions & 329 deletions

File tree

README.md

Lines changed: 96 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -2,190 +2,190 @@
22
<img alt="logo" src="resources/img/logo.png" width="50%">
33
</p>
44
<p align="center">
5-
<strong>基于配置中心的轻量级动态线程池,内置监控告警功能,集成常用中间件线程池管理,可通过SPI自定义扩展实现</strong>
5+
<strong>A lightweight dynamic thread pool based on configuration centers, with built-in monitoring & alerting, middleware thread pool management, and SPI extensibility</strong>
66
</p>
77

88
<p align="center">
99
<a href="https://gitee.com/dromara/dynamic-tp"><img src="https://gitee.com/dromara/dynamic-tp/badge/star.svg"></a>
1010
<a href="https://gitee.com/dromara/dynamic-tp/members"><img src="https://gitee.com/dromara/dynamic-tp/badge/fork.svg"></a>
1111
<a href="https://github.com/dromara/dynamic-tp"><img src="https://img.shields.io/github/stars/dromara/dynamic-tp?style=flat-square&logo=github"></a>
1212
<a href="https://github.com/dromara/dynamic-tp/network/members"><img src="https://img.shields.io/github/forks/dromara/dynamic-tp?style=flat-square&logo=GitHub"></a>
13-
<a href='https://gitcode.com/dromara/dynamic-tp'><img src='https://gitcode.com/dromara/dynamic-tp/star/badge.svg' alt='fork'></a>
13+
<a href='https://gitcode.com/dromara/dynamic-tp'><img src='https://gitcode.com/dromara/dynamic-tp/star/badge.svg' alt='star'></a>
1414
<a href="https://github.com/dromara/dynamic-tp/blob/master/LICENSE"><img src="https://img.shields.io/github/license/dromara/dynamic-tp.svg?style=flat-square"></a>
1515
</p>
1616

1717
<p align="center">
18-
🌐 中文 | <a href="README_EN.md">English</a>
18+
🌐 <a href="README_CN.md">中文</a> | English
1919
</p>
2020

2121
<p align="center">
22-
官网: <a href="https://dynamictp.cn">https://dynamictp.cn</a> 🔥
22+
Website: <a href="https://dynamictp.cn">https://dynamictp.cn</a> 🔥
2323
</p>
2424

2525
---
2626

27-
## 痛点
27+
## Pain Points
2828

29-
使用线程池 ThreadPoolExecutor 过程中你是否有以下痛点呢?
29+
Have you encountered these issues when using `ThreadPoolExecutor`?
3030

31-
> 1. 代码中创建了一个 ThreadPoolExecutor,但是不知道那几个核心参数设置多少比较合适
31+
> 1. You created a `ThreadPoolExecutor`, but have no idea what values to set for the core parameters.
3232
>
33-
> 2. 凭经验设置参数值,上线后发现需要调整,改代码重新发布服务,非常麻烦
33+
> 2. You set parameters based on experience, only to find after deployment that they need adjustment — requiring code changes and redeployment.
3434
>
35-
> 3. 线程池相对开发人员来说是个黑盒,运行情况不能及时感知到,直到出现问题
35+
> 3. Thread pools are a black box to developers. You can't monitor their behavior until something breaks.
3636
37-
如果有以上痛点,动态可监控线程池框架(**DynamicTp**)或许能帮助到你。
37+
If so, **DynamicTp** may be the solution.
3838

39-
如果看过 ThreadPoolExecutor 的源码,大概可以知道它对核心参数基本都有提供 set / get 方法以及一些扩展方法,可以在运行时动态修改、获取相应的值,这些方法有:
39+
`ThreadPoolExecutor` provides set/get methods and extension points for its core parameters, enabling runtime dynamic modification.
4040

4141
<details>
42-
<summary>👉 ThreadPoolExecutor 提供的动态方法(点击展开)</summary>
42+
<summary>👉 ThreadPoolExecutor dynamic methods (click to expand)</summary>
4343

4444
```java
45-
public void setCorePoolSize(int corePoolSize); // 核心线程数
46-
public void setMaximumPoolSize(int maximumPoolSize); // 最大线程数
47-
public void setKeepAliveTime(long time, TimeUnit unit); // 线程空闲存活时间
48-
public void setThreadFactory(ThreadFactory threadFactory); // 线程工厂
49-
public void setRejectedExecutionHandler(RejectedExecutionHandler handler); // 拒绝策略
50-
public void allowCoreThreadTimeOut(boolean value); // 核心线程是否允许超时
51-
45+
// --- Set ---
46+
public void setCorePoolSize(int corePoolSize); // core pool size
47+
public void setMaximumPoolSize(int maximumPoolSize); // max pool size
48+
public void setKeepAliveTime(long time, TimeUnit unit); // thread idle keep-alive time
49+
public void setThreadFactory(ThreadFactory threadFactory); // thread factory
50+
public void setRejectedExecutionHandler(RejectedExecutionHandler handler); // rejection policy
51+
public void allowCoreThreadTimeOut(boolean value); // allow core threads to time out
52+
53+
// --- Get ---
5254
public int getCorePoolSize();
5355
public int getMaximumPoolSize();
5456
public long getKeepAliveTime(TimeUnit unit);
55-
public BlockingQueue<Runnable> getQueue(); // 任务队列
57+
public BlockingQueue<Runnable> getQueue(); // task queue
5658
public RejectedExecutionHandler getRejectedExecutionHandler();
5759
public boolean allowsCoreThreadTimeOut();
5860

59-
protected void beforeExecute(Thread t, Runnable r); // 任务执行前
60-
protected void afterExecute(Runnable r, Throwable t); // 任务执行后
61+
// --- Extension hooks ---
62+
protected void beforeExecute(Thread t, Runnable r); // before task execution
63+
protected void afterExecute(Runnable r, Throwable t); // after task execution
6164
```
6265

6366
</details>
6467

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.
6769

68-
那么我们是否可以结合配置中心来做运行时线程池参数的动态调整呢?
70+
So, can we combine a configuration center to dynamically adjust thread pool parameters at runtime?
6971

70-
答案是肯定的,而且配置中心相对都是高可用的,使用它也不用过于担心配置推送失败这类问题,而且也能减少研发动态线程池组件本身的难度和接入的工作量。
72+
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.
7173

72-
**综上,可以总结出以下的背景**
74+
**Background summary:**
7375

74-
- **广泛性**:在 Java 开发中,想要提高系统性能,线程池已经是一个 90% 以上开发人员都会选择使用的基础工具
76+
- **Ubiquity**: Thread pools are a fundamental tool used by 90%+ of Java developers to improve system performance.
7577

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.
7779

78-
- **无感知性**:线程池运行过程中的各项指标一般感知不到,需要有套监控报警机制在事前、事中就能让开发人员感知到线程池的运行状况,及时处理
80+
- **Lack of visibility**: Thread pool metrics are invisible during operation. A monitoring & alerting mechanism is needed to detect issues before and during incidents.
7981

80-
- **高可用性**:配置变更需要及时推送到客户端,需要有高可用的配置管理推送服务,配置中心是现在大多数互联网系统都会使用的组件,与之结合可以极大提高系统可用性
82+
- **High availability**: Configuration changes must be reliably pushed to clients. Leveraging an existing configuration center greatly improves system availability.
8183

8284
---
8385

84-
## 功能特性
86+
## Features
8587

86-
基于以上背景分析,我们对线程池 ThreadPoolExecutor 做一些扩展增强,主要实现以下目标
88+
Based on the above analysis, we extended `ThreadPoolExecutor` with the following goals:
8789

88-
> 1. 实现对运行中线程池参数的动态修改,实时生效
90+
> 1. Dynamic parameter modification at runtime, taking effect instantly.
8991
>
90-
> 2. 实时监控线程池的运行状态,触发设置的报警策略时报警,报警信息推送办公平台
92+
> 2. Real-time monitoring of thread pool status with alerting, pushing notifications to office platforms.
9193
>
92-
> 3. 定时采集线程池指标数据,配合像 Grafana 这种可视化监控平台做大盘监控
94+
> 3. Periodic metric collection, integrated with visualization platforms like Grafana for dashboards.
9395
>
94-
> 4. 集成常用三方中间件内部线程池管理
96+
> 4. Thread pool management for commonly used third-party middleware.
9597
96-
**经过多个版本的迭代,目前最新版本 v1.2.2 具有以下特性**
98+
**Latest version features:**
9799

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.
99101

100-
- **轻量简单**:使用起来极其简单,引入相应依赖,接入只需简单 4 步就可完成,顺利 3 分钟搞定,相当丝滑
102+
- **Lightweight & simple**: Get started in 3 minutes with just 4 steps. Simply add the dependency, configure, annotate, and inject.
101103

102-
- **通知告警**:提供多种通知告警维度(配置变更通知、活性报警、队列容量阈值报警、拒绝触发报警、任务执行或等待超时报警),触发配置阈值实时推送告警信息,已支持企微、钉钉、飞书、邮件、云之家报警,同时提供 SPI 接口可自定义扩展实现
104+
- **Notifications & alerting**: Multiple alert dimensions (config change, thread activity, queue capacity, rejection, task execution/wait timeout). Supports WeCom, DingTalk, Feishu, Email, and extensible via SPI.
103105

104-
- **运行监控**:定时采集线程池指标数据(20 多种指标,包含线程池维度、队列维度、任务维度、tps、tpxx 等),支持通过 MicroMeterJsonLogJMX 三种方式定时获取,也可以通过 SpringBoot Endpoint 端点实时获取最新指标数据,同时提供 SPI 接口可自定义扩展实现
106+
- **Monitoring**: 20+ metrics (pool, queue, task, TPS, TPxx) collected via MicroMeter, JsonLog, JMX, or Spring Boot Endpoint. Extensible via SPI.
105107

106-
- **任务增强**:提供任务包装功能(比 Spring 线程池任务包装更强大),实现 TaskWrapper 接口即可,如 MdcTaskWrapperTtlTaskWrapper、SwTraceTaskWrapper、OpenTelemetryWrapper,可以支持线程池上下文信息传递
108+
- **Task enhancement**: Powerful task wrapping (stronger than Spring's built-in). Implement `TaskWrapper` interface for MDC, TTL, trace context propagation (e.g., MdcTaskWrapper, TtlTaskWrapper, OpenTelemetryWrapper).
107109

108-
- **多配置中心支持**:支持多种主流配置中心,包括 NacosApolloZookeeperConsulEtcdPolarisServiceComb,同时也提供 SPI 接口可自定义扩展实现
110+
- **Multi configuration center support**: Nacos, Apollo, Zookeeper, Consul, Etcd, Polaris, ServiceComb. Extensible via SPI.
109111

110-
- **中间件线程池管理**:集成管理常用第三方组件的线程池,已集成 TomcatJettyUndertowDubbo、RocketMq、Hystrix、Grpc、Motan、Okhttp3、BrpcTars、SofaRpc、RabbitMq、LiteflowThrift 等组件的线程池管理(动态调参、监控、报警)
112+
- **Middleware thread pool management**: Integrated with Tomcat, Jetty, Undertow, Dubbo, RocketMQ, Hystrix, gRPC, Motan, OkHttp3, Brpc, Tars, SofaRPC, RabbitMQ, Liteflow, Thrift (dynamic tuning, monitoring, alerting).
111113

112-
- **多模式**:提供了增强线程池 DtpExecutor,IO 密集型场景使用的线程池 EagerDtpExecutor,调度线程池 ScheduledDtpExecutor,有序线程池 OrderedDtpExecutor,可以根据业务场景选择合适的线程池
114+
- **Multiple pool modes**: `DtpExecutor` (enhanced), `EagerDtpExecutor` (IO-intensive), `ScheduledDtpExecutor` (scheduled), `OrderedDtpExecutor` (ordered). Choose based on your scenario.
113115

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.
115117

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.
117119

118-
- **高可扩展**:框架核心功能都提供 SPI 接口供用户自定义个性化实现(配置中心、配置文件解析、通知告警、监控数据采集、任务包装、拒绝策略等等)
120+
- **Highly extensible**: Core features expose SPI interfaces for custom implementations (config center, config parsing, alerting, metrics collection, task wrapping, rejection policies, etc.).
119121

120-
- **线上大规模应用**:参考[美团线程池实践](https://tech.meituan.com/2020/04/02/java-pooling-pratice-in-meituan.html),美团内部已经有该理论成熟的应用经验
122+
- **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.
121123

122124
---
123125

124-
## 架构设计
126+
## Architecture
125127

126-
**框架功能大体可以分为以下几个模块**
128+
**The framework is divided into the following modules:**
127129

128-
> 1. 配置变更监听模块
130+
> 1. Configuration change listener
129131
>
130-
> 2. 线程池管理模块
132+
> 2. Thread pool management
131133
>
132-
> 3. 监控模块
134+
> 3. Monitoring
133135
>
134-
> 4. 通知告警模块
136+
> 4. Notification & alerting
135137
>
136-
> 5. 三方组件线程池管理模块
138+
> 5. Third-party middleware thread pool management
137139
138-
![技术架构](resources/img/arch.svg)
140+
![Architecture](resources/img/arch.svg)
139141

140-
详细查看官网文档,[架构设计](https://dynamictp.cn/guide/introduction/architecture.html)
142+
See the official documentation for details: [Architecture](https://dynamictp.cn/guide/introduction/architecture.html)
141143

142144
---
143145

144-
## 接入步骤
146+
## Quick Start
145147

146-
> 1. 引入相应配置中心的依赖,具体见官网文档
147-
>
148-
> 2. 配置中心配置线程池实例,配置文件见官网文档
148+
> 1. Add the dependency for your configuration center (see official docs).
149149
>
150-
> 3. 启动类加 @EnableDynamicTp 注解
150+
> 2. Configure thread pool instances in your configuration center (see official docs).
151151
>
152-
> 4. 使用 @Resource@Autowired 进行依赖注入,或通过 DtpRegistry.getExecutor("name") 获取
152+
> 3. Add `@EnableDynamicTp` annotation to your application class.
153153
>
154-
> 5. 通过以上 4 步就可以使用了,是不是感觉超级简单呀
154+
> 4. Inject via `@Resource` / `@Autowired`, or retrieve with `DtpRegistry.getExecutor("name")`.
155155
156-
更详细使用示例请参考 `example` 工程及[官网文档](https://dynamictp.cn/guide/use/quick-start.html)
156+
For detailed examples, see the `example` module and the [official documentation](https://dynamictp.cn/guide/use/quick-start.html).
157157

158158
---
159159

160-
## 通知报警
160+
## Alerting
161161

162-
- 触发报警阈值会推送相应报警消息(活性、容量、拒绝、任务等待超时、任务执行超时),且会高亮显示相应字段
162+
- Alert notifications are pushed when thresholds are triggered (thread activity, queue capacity, rejection, task wait/execution timeout), with highlighted fields.
163163

164-
<img src="resources/img/alarm.jpg" alt="告警" width="50%" />
164+
<img src="resources/img/alarm.jpg" alt="Alert" width="50%" />
165165

166-
- 配置变更会推送通知消息,且会高亮变更的字段
166+
- Configuration change notifications are pushed with highlighted changed fields.
167167

168-
<img src="resources/img/notice.jpg" alt="变更通知" width="50%" />
168+
<img src="resources/img/notice.jpg" alt="Config Change Notification" width="50%" />
169169

170170
---
171171

172-
## 监控
172+
## Monitoring
173173

174-
![监控数据1](resources/img/monitor1.jpg)
175-
![监控数据2](resources/img/monitor2.jpg)
176-
![监控数据3](resources/img/monitor3.jpg)
174+
![Monitoring Data 1](resources/img/monitor1.jpg)
175+
![Monitoring Data 2](resources/img/monitor2.jpg)
176+
![Monitoring Data 3](resources/img/monitor3.jpg)
177177

178-
目前框架提供了四种监控数据采集方式,通过 collectorTypes 属性配置监控指标采集类型,默认 Micrometer
178+
Four metric collection modes are available, configured via `collectorTypes` (default: Micrometer):
179179

180-
> 1. Logging:线程池指标数据会以 Json 格式输出到指定的日志文件里
180+
> 1. **Logging**: Metrics output as JSON to a dedicated log file.
181181
>
182-
> 2. Internal_logging:线程池指标数据会以 Json 格式输出到项目日志文件里
182+
> 2. **Internal_logging**: Metrics output as JSON to the application log.
183183
>
184-
> 3. Micrometer:采用监控门面,通过引入相关 Micrometer 依赖采集到相应的存储平台里(如 Prometheus,InfluxDb...)
184+
> 3. **Micrometer**: Uses the Micrometer facade to collect metrics into storage platforms (Prometheus, InfluxDB, etc.).
185185
>
186-
> 4. Endpoint:暴露 Endpoint 端点,可以通过 http 方式实时获取指标数据
186+
> 4. **Endpoint**: Exposes a Spring Boot Endpoint for real-time metric retrieval via HTTP.
187187
188-
> 📖 更多详细用法见官网文档:[通知报警](https://dynamictp.cn/guide/notice/alarm.html) [监控](https://dynamictp.cn/guide/monitor/collect_types.html)
188+
> 📖 See the official documentation for details: [Alerting](https://dynamictp.cn/guide/notice/alarm.html) | [Monitoring](https://dynamictp.cn/guide/monitor/collect_types.html)
189189
190190
---
191191

@@ -195,39 +195,38 @@ protected void afterExecute(Runnable r, Throwable t); // 任务执
195195

196196
---
197197

198-
## 代码托管
198+
## Repository
199199

200-
- github: https://github.com/dromara/dynamic-tp
201-
- gitee: https://gitee.com/dromara/dynamic-tp
202-
- gitcode: https://gitcode.com/dromara/dynamic-tp
200+
- GitHub: https://github.com/dromara/dynamic-tp
201+
- Gitee: https://gitee.com/dromara/dynamic-tp
202+
- GitCode: https://gitcode.com/dromara/dynamic-tp
203203

204204
---
205205

206-
## 联系我
206+
## Contact
207207

208-
看到这儿,**请给项目一个 star**,你的支持是我们前进的动力!
208+
If you find this project helpful, **please give us a star** — your support drives us forward!
209209

210-
使用过程中有任何问题,或者对项目有什么想法或者建议,可以加入社群,跟 1700+ 群友一起交流讨论。
210+
For questions, ideas, or suggestions, join our community to chat with 1700+ members.
211211

212-
微信群均已满 200 人,可以关注微信公众号,加我个人微信拉群(备注:dynamic-tp 拉群)。
212+
Follow the WeChat public account and add my personal WeChat (note: dynamic-tp) to join the group.
213213

214214
![](resources/img/contact.jpg)
215215

216-
为了项目更好的发展,请在此进行登记,[使用登记](https://dynamictp.cn/guide/other/users.html)
216+
To help the project grow, please register here: [User Registration](https://dynamictp.cn/guide/other/users.html)
217217

218218
---
219219

220-
## 赞助商
220+
## Sponsors
221221

222-
- Easysearch:企业级的分布式搜索型数据库
222+
- Easysearch: Enterprise-grade distributed search database.
223223

224224
<a href="https://easysearch.cn/" target="_blank">
225-
<img class="no-zoom" src="/resources/img/easysearch.png" width="50%" height="50%"/>
225+
<img class="no-zoom" src="resources/img/easysearch.png" width="50%" height="50%"/>
226226
</a>
227227

228228
---
229229

230-
## 友情链接
231-
232-
- [HertzBeat](https://github.com/dromara/hertzbeat) : 易用友好的实时监控告警系统,无需Agent,强大自定义监控能力.
230+
## Related Projects
233231

232+
- [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

Comments
 (0)