Coder Social home page Coder Social logo

zhuchen1990 / dynamic-thread-pool Goto Github PK

View Code? Open in Web Editor NEW

This project forked from imyzt/dynamic-thread-pool

0.0 1.0 0.0 88 KB

A framework for dynamically modifying the Java / Spring thread pool, which supports dynamically modifying the created thread pool, including increasing the core thread pool, maximum thread pool, and queue size. Support to view the running status of threads in the past 24h, support configuration monitoring alarm and automatic expansion of work queue

License: Apache License 2.0

Java 100.00%

dynamic-thread-pool's Introduction

介绍

​ 看了美团 Java线程池实现原理及其在美团业务中的实践 这篇文章之后,对线程池有了一些新的认识,后面看到了 如何设置线程池参数?美团给出了一个让面试官虎躯一震的回答 四川好男人的一顿*操作,瞬间又认识的更清晰了一些。就想着能不能做一套这样的线程池管理系统,然后就有了后文。

​ Web应用系统中,ThreadPoolExecutor一般是由代码硬编码的,core/max/queueSize都是定数,而系统的流量不是一个定数。在峰值期间,线程池无法动态扩容,导致大量请求处理失败进行拒绝策略。本系统主要是做了一个可以动态调参的线程池,依赖ThreadPoolExecutor本身提供的set方法,对运行中的各项基本参数进行动态调控。并且包括监控报警、Web界面、自动扩容策略等。

设计

架构图

实现

客户端

配置文件需配置服务端地址

线程池配置需配置线程池(三种接入方式)

  1. 接入方式, 提供三种[##feature]

  2. 启动时,携带应用名上报对应的线程池配置(多实例同时启动, 此接口需要幂等)

  3. 通过Java定时器,定时上报线程池数据。

  4. 与服务端维持长连接,60秒一次,服务端线程池配置(web操作)变化时,返回对应发生改变的[线程池名称]。然后客户端请求服务端获取对应线程池新的配置。

服务端

  1. 上报接口

    1.1 配置上报接口(配置带版本号)

    1.1.1 初次上报(数据库无法查询, 即视为初次上报), 存储初始化参数

    1.1.2 服务端Web发起调参, 自行记录, 无需客户端上报(可优化为客户端上报)

    1.2 工作状态上报接口

    ​ 1.2.1 定时上报应用每个线程池各项指标

  2. 发起调参后,接受客户端请求最新线程池参数请求

  3. 存储上报数据, 负责提供数据展示接口,读取数据

feature

  1. 接入方式新增, 除了Dynamic,让默认的Spring的task和jdk的executor都支持,只有dynamic支持修改队列大小。

todo-list

https://github.com/imyzt/dynamic-thread-pool/projects/1

dynamic-thread-pool's People

Contributors

imyzt avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.