Why write this project?
Hello, I’m Longtai.
In the introduction of thread pool in Meituan, several production accidents were triggered due to the improper configuration of thread pool parameters by businesses, which led to a series of thinking. The final decision is to encapsulate thread pool dynamic parameter adjustment, extend thread pool monitoring and message alarm functions
I have found a lot of dynamic thread pool projects on open source platforms, but I feel they are not suitable for enterprise applications in terms of functionality and robustness
Interested in dynamic thread pools and writing a meaningful project, I decided to build a lightweight wheel myself
Wanted to give the project a name that was easy to remember, like Eureka, Nacos, Redis; Later to discuss with friends, decided to name after the animal: Hippo (hippopotamus)
Hippo GitHub:github.com/acmenlt/dyn…
Feel helpful, hard point a Star, thank you
What problem does it solve?
Thread pools should be used in all business systems to help business processes improve efficiency and manage threads, in most cases for large amounts of asynchronous task processing
While thread pools offer a lot of benefits, they are not perfect, and the following problems are not easy to solve
If the configuration of thread pools involves any of these issues, you may need to publish a business system to solve them. If the parameters are still incorrect, continue to publish……
Hippo solves this problem by unifying the management of all thread pools in the business and replacing thread pool parameters without publishing the system
What are its properties?
Thread pools in application systems are not easy to manage. Referring to the design of Meituan, Hippo is divided into tenant, project and thread pool dimensions. In addition, system permissions allow different developers and administrators to be responsible for their own system’s thread pool operations
For example, xiaobian works on a company’s common Components team, which is responsible for messaging, short link gateways, and so on. The common component is the tenant, and the message or short link is the project
The module | The name of the module | annotation |
---|---|---|
dynamic-threadpool-common | Public module | – |
dynamic-threadpool-config | Configuration center | Provides the thread pool quasi-real-time update function |
dynamic-threadpool-console | The console | Docking front end project |
dynamic-threadpool-discovery | The registry | Provides thread pool project instance registration, renewal, offline and other functions |
dynamic-threadpool-spring-boot-starter | SpringBoot Starter | – |
dynamic-threadpool-example | The sample project | – |
dynamic-threadpool-server | The service side | Server integrates components |
dynamic-threadpool-tools | Abstract tool class | Swagger, operation log, and other components |
In addition to dynamically modifying the thread pool, Hippo also includes real-time viewing of thread pool runtime metrics, load alerts, configuration log management, and more. The specific functions are shown below
How do I run Demo?
Now that the dynamic thread pool feature is complete, you can pull code directly to run locally. The database in the project is built by the author ECS Docker, and you can use it directly
- Start the
dynamic-threadpool-server
Module ServerApplication application class - Start the
dynamic-threadpool-example
ExampleApplication application class under the module
Modify the configuration in the thread pool through the interface. HTTP POST path: http://localhost:6691/v1/cs/configs, Body request Body is as follows:
{"ignore": "tenantId": "prescription", "itemId": "dynamic-threadpool-example", "tpId": "message-produce", "coreSize": 10, "maxSize": 15, "queueType": 9, "capacity": 100, "keepAliveTime": 10, "rejectedType": 7, "isAlarm": 0, "capacityAlarm": 81, "livenessAlarm": 82 }Copy the code
After the interface is successfully invoked, observe the dynamic-threadpool-example console log output. If the log output includes but is not limited to this information, the interface is successfully invoked
CoreSize :: [11=>10], maxSize :: [15=>15], queueType :: [9=>9] Capacity :: [100=>100], keepAliveTime :: [10000=>10000], rejectedType :: [7=>7]Copy the code
At present, It has integrated Dingding message push, and will continue to access enterprise wechat, mailbox, feishu, SMS and other notification channels in the future. You can experience the notification push by adding the group number: 31764717
Configuration changes | Warning notice |
---|
The code functions of the project are still under continuous development, and the following functions will be completed with the initial RELEASE of 1.0.0 RELEASE. After the Server service is deployed, you only need to introduce the Starter component to the service system to implement features such as dynamic change, monitoring, and alarm
What can be gained from looking at the source code?
No Release version has been released yet. You can read the source code of the framework to see good design ideas or coding skills in the framework
In the process of project development, the elegant design of middleware projects such as Nacos, Eureka, Seata and ShardingSphere was used for reference
review
Xiaobian is a programmer who is obsessed with code cleanliness. The code development in the project is in full compliance with the Code regulations of Alibaba. We also recommend everyone to use it to develop good coding habits
If you think the functional planning and code design of the project are not bad, please click 🚀 Star to facilitate subsequent viewing
Do you have any different opinions about this project? Please feel free to communicate in the comments section