You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hippo4j/README.md

222 lines
9.6 KiB

3 years ago
<div align=center>
3 years ago
<img src="https://images-machen.oss-cn-beijing.aliyuncs.com/Dynamic-Thread-Pool-Main.jpeg" />
3 years ago
</div>
<p align="center">
3 years ago
<strong> :fire: &nbsp; 动态线程池Hippo4J系统包含 <a href="https://github.com/acmenlt/dynamic-threadpool/tree/develop/dynamic-threadpool-server">Server</a> 端及 SpringBoot Client 端需引入的 <a href="https://github.com/acmenlt/dynamic-threadpool/tree/develop/dynamic-threadpool-spring-boot-starter">Starter</a>.</strong>
</p>
<p align="center">
3 years ago
<img src="https://img.shields.io/badge/Author-龙台-blue.svg" />
3 years ago
<a target="_blank" href="http://mp.weixin.qq.com/s?__biz=Mzg4NDU0Mjk5OQ==&mid=100007373&idx=1&sn=3b375f97a576820e3e540810e720aeb0&chksm=4fb7c6b578c04fa35fab488d8dd6ddd12cfd0ef70290f3b285261fba0750785ea2725a50d508&scene=18#wechat_redirect">
<img src="https://img.shields.io/badge/公众号-龙台 blog-yellow.svg" />
</a>
3 years ago
<a target="_blank" href="https://github.com/acmenlt/dynamic-threadpool">
<img src="https://img.shields.io/badge/⭐-github-orange.svg" />
</a>
3 years ago
<a href="https://github.com/acmenlt/dynamic-threadpool/blob/develop/LICENSE">
<img src="https://img.shields.io/github/license/acmenlt/dynamic-threadpool?color=42b883&style=flat-square" alt="LICENSE">
</a>
3 years ago
<img src="https://img.shields.io/badge/JDK-1.8+-green?logo=appveyor" />
3 years ago
<img src="https://tokei.rs/b1/github/acmenlt/dynamic-threadpool?category=lines" />
3 years ago
3 years ago
<img src="https://img.shields.io/badge/version-v0.4.0-DeepSkyBlue.svg" />
3 years ago
<img src="https://img.shields.io/github/stars/acmenlt/dynamic-threadpool.svg" />
</p>
<br/>
3 years ago
## 为什么写这个项目?
3 years ago
[美团线程池文章](https://tech.meituan.com/2020/04/02/java-pooling-pratice-in-meituan.html "美团线程池文章") 介绍中,因为业务对线程池参数没有合理配置,触发过几起生产事故,进而引发了一系列思考。最终决定封装线程池动态参数调整,扩展线程池监控以及消息报警等功能
3 years ago
3 years ago
在开源平台找了挺多动态线程池项目,从功能性以及健壮性而言,个人感觉不满足企业级应用
3 years ago
因为对动态线程池比较感兴趣,加上想写一个有意义的项目,所以决定自己来造一个轻量级的轮子
3 years ago
3 years ago
想给项目起一个简单易记的名字,类似于 Eureka、Nacos、Redis后和朋友商量决定以动物命名**Hippo4J**
3 years ago
3 years ago
![](https://user-images.githubusercontent.com/77398366/139702684-17595e6e-a743-4a33-a0be-0626967f32f5.png)
3 years ago
<br/>
3 years ago
## 它解决了什么问题?
3 years ago
线程池在业务系统应该都有使用到,帮助业务流程提升效率以及管理线程,多数场景应用于大量的异步任务处理
3 years ago
虽然线程池提供了我们许多便利,但也并非尽善尽美,比如下面这些问题就无法很好解决
3 years ago
![](https://images-machen.oss-cn-beijing.aliyuncs.com/image-20211023160830084.png)
3 years ago
<br/>
3 years ago
如果线程池的配置涉及到上述问题,那么就有可能需要发布业务系统来解决;如果发布后参数仍不合理,继续发布......
3 years ago
Hippo4J 很好解决了这个问题,它将业务中所有线程池统一管理,遇到上述问题不需要发布系统就可以替换线程池参数
3 years ago
![](https://images-machen.oss-cn-beijing.aliyuncs.com/image-20211023142726818.png)
<br/>
3 years ago
## 它有什么特性?
3 years ago
应用系统中线程池并不容易管理。参考美团的设计Hippo4J 按照租户、项目、线程池的维度划分。再加上系统权限,让不同的开发、管理人员负责自己系统的线程池操作
3 years ago
举个例子,小编在一家公司的公共组件团队,团队中负责消息、短链接网关等项目。公共组件是租户,消息或短链接就是项目
3 years ago
<br/>
| 模块 | 模块名称 | 注释 |
| -------------------------------------- | ------------------ | ---------------------------------------- |
3 years ago
| hippo4j-auth | 用户权限 | 用户、角色、权限等功能 |
| hippo4j-common | 公共模块 | - |
| hippo4j-config | 配置中心 | 提供线程池准实时更新功能 |
| hippo4j-console | 控制台 | 对接前端项目 |
| hippo4j-discovery | 注册中心 | 提供线程池项目实例注册、续约、下线等功能 |
3 years ago
| hippo4j-spring-boot-starter | Starter | 客户端依赖组件 |
3 years ago
| hippo4j-example | 示例项目 | - |
| hippo4j-server | 服务端 | Server 集成各组件 |
| hippo4j-tools | 抽象工具类 | GitHub 变更监控、操作日志等组件 |
3 years ago
<br/>
3 years ago
Hippo4J 除去动态修改线程池,还包含实时查看线程池运行时指标、负载报警、配置日志管理等
3 years ago
3 years ago
![](https://images-machen.oss-cn-beijing.aliyuncs.com/image-20211023101844619.png)
<br/>
3 years ago
## 如何运行 Demo
3 years ago
目前动态线程池功能已经完成,可以直接把代码拉到本地运行。导入 [Hippo4J 初始化 SQL 语句](https://github.com/acmenlt/dynamic-threadpool/blob/develop/server/src/main/resources/hippo_manager.sql)
3 years ago
3 years ago
1. 启动 `hippo4j-server` 模块下 ServerApplication 应用类
2. 启动 `hippo4j-example` 模块下 ExampleApplication 应用类
> 🌟 &nbsp; Hippo4J 已集成前端项目,详情参考 [Run Console](http://hippox.cn/zh-cn/docs/run/runConsole.html)
<br/>
3 years ago
通过接口修改线程池中的配置。HTTP POST 路径http://localhost:6691/v1/cs/configs Body 请求体如下:
3 years ago
```json
{
3 years ago
"ignore": "tenantId、itemId、tpId 代表唯一线程池,请不要修改",
3 years ago
"tenantId": "prescription",
"itemId": "dynamic-threadpool-example",
3 years ago
"tpId": "message-produce",
3 years ago
"coreSize": 10,
"maxSize": 15,
"queueType": 9,
3 years ago
"capacity": 100,
"keepAliveTime": 10,
3 years ago
"rejectedType": 3,
3 years ago
"isAlarm": 0,
"capacityAlarm": 81,
"livenessAlarm": 82
}
```
<br/>
3 years ago
接口调用成功后,观察 dynamic-threadpool-example 控制台日志输出,日志输出包括不限于此信息即为成功
```tex
3 years ago
[🔥 MESSAGE-PRODUCE] Changed thread pool. coreSize :: [11=>10], maxSize :: [15=>15], queueType :: [9=>9]
3 years ago
capacity :: [100=>100], keepAliveTime :: [10000=>10000], rejectedType :: [7=>7]
```
<br/>
3 years ago
现阶段已集成钉钉消息推送后续会持续接入企业微信、邮箱、飞书、短信等通知渠道。可以通过添加钉钉群体验消息推送群号31764717
3 years ago
<table>
<tr>
<td align="center" style="width: 200px;">
<a href="https://github.com/acmenlt">
<img src="https://images-machen.oss-cn-beijing.aliyuncs.com/image-20211013122816688.png" style="width: 400px;"><br>
<sub>配置变更</sub>
</a><br>
</td>
<td align="center" style="width: 200px;">
<a href="https://github.com/acmenlt">
<img src="https://images-machen.oss-cn-beijing.aliyuncs.com/image-20211013113649068.png" style="width: 400px;"><br>
3 years ago
<sub>报警通知</sub>
3 years ago
</a><br>
</td>
</tr>
</table>
<br/>
3 years ago
项目代码功能还在持续开发,初定发布 1.0.0 RELEASE 完成以下功能。部署了 Server 服务,只需要引入 Starter 组件到业务系统中,即可完成动态修改、监控、报警等特性
3 years ago
<br/>
## 查看源码能收获什么?
3 years ago
目前还没有发布 Release 版本,小伙伴可以阅读框架源码,查看框架中好的设计理念或者编码技巧
3 years ago
在项目开发过程中,借鉴了 Nacos、Eureka、Seata、ShardingSphere 等中间件项目的优雅设计
3 years ago
![](https://images-machen.oss-cn-beijing.aliyuncs.com/image-20211023143632685.png)
3 years ago
<br/>
3 years ago
## Github Stars 趋势
3 years ago
如果小伙伴查看源码设计有所收获,辛苦点个 🚀 Star ,方便后续查看
3 years ago
3 years ago
[![Stargazers over time](https://starchart.cc/acmenlt/dynamic-threadpool.svg)](https://starchart.cc/acmenlt/dynamic-threadpool)
3 years ago
<br/>
3 years ago
## 致谢
3 years ago
Hippo4J 项目基于或参考以下项目:
3 years ago
1. [Nacos](https://github.com/alibaba/nacos)an easy-to-use dynamic service discovery, configuration and service management platform for building cloud native applications.
2. [Eureka](https://github.com/Netflix/Eureka)AWS Service registry for resilient mid-tier load balancing and failover.
3. [ShardingSphere](https://github.com/apache/shardingsphere)Build criterion and ecosystem above multi-model databases
4. [mzt-biz-log](https://github.com/mouzt/mzt-biz-log)支持Springboot基于注解的可使用变量、可以自定义函数的通用操作日志组件
5. [equator](https://github.com/dadiyang/equator):一个用于比较两个对象的所有属性是否全部相等,并且可以获取所有不相等的属性的比对器
<br/>
3 years ago
## 最后
3 years ago
小编是个有代码洁癖的程序员,项目中的代码开发完全遵守阿里巴巴代码规约,也推荐大家使用,培养好的编码习惯
3 years ago
对于这个项目,是否有什么不一样看法,欢迎在 Issue 一起沟通交流;或者添加小编微信进交流群
3 years ago
<table>
<tr>
<td align="center" style="width: 200px;">
<a href="https://github.com/acmenlt">
<img src="https://images-machen.oss-cn-beijing.aliyuncs.com/64E583A0-B1DD-49A3-9AEC-8D246E9D5C12.PNG" style="width: 400px;"><br>
<sub></sub>
</a><br>
</td>
<td align="center" style="width: 200px;">
<a href="https://github.com/acmenlt">
<img src="https://images-machen.oss-cn-beijing.aliyuncs.com/IMG_6583.JPG?x-oss-process=image/resize,h_500,w_800" style="width: 400px;"><br>
<sub></sub>
</a><br>
</td>
</tr>
</table>