mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-12 19:29:52 +08:00
修改线程池配置
This commit is contained in:
@@ -22,16 +22,32 @@ public class ThreadPoolConfig {
|
|||||||
Logger log = LoggerFactory.getLogger(ThreadPoolConfig.class);
|
Logger log = LoggerFactory.getLogger(ThreadPoolConfig.class);
|
||||||
|
|
||||||
// 核心线程池大小
|
// 核心线程池大小
|
||||||
private final int corePoolSize = 500;
|
private final int corePoolSize = 64; // 8 核 × 8,满足高 IO 阻塞场景
|
||||||
|
|
||||||
// 最大可创建的线程数
|
// 最大可创建的线程数
|
||||||
private final int maxPoolSize = 1000;
|
private final int maxPoolSize = 128; // 突发时翻倍,避免过多上下文切换
|
||||||
|
|
||||||
// 队列最大长度
|
// 队列最大长度
|
||||||
private final int queueCapacity = 1000;
|
private final int queueCapacity = 2000; // 桩消息短时堆积时提供缓冲,防止直接拒绝
|
||||||
|
|
||||||
// 线程池维护线程所允许的空闲时间
|
// 线程池维护线程所允许的空闲时间
|
||||||
private final int keepAliveSeconds = 300;
|
private final int keepAliveSeconds = 120; // 突发结束后快速回收扩展线程
|
||||||
|
|
||||||
|
private final String threadNamePrefix = "pile-io-";
|
||||||
|
|
||||||
|
// 核心线程池大小
|
||||||
|
private final int corePoolSize_tp = 24;
|
||||||
|
|
||||||
|
// 最大可创建的线程数
|
||||||
|
private final int maxPoolSize_tp = 60;
|
||||||
|
|
||||||
|
// 队列最大长度
|
||||||
|
private final int queueCapacity_tp = 1000;
|
||||||
|
|
||||||
|
// 线程池维护线程所允许的空闲时间
|
||||||
|
private final int keepAliveSeconds_tp = 180;
|
||||||
|
|
||||||
|
private final String threadNamePrefix_tp = "thirdparty-push-";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 线程池
|
* 线程池
|
||||||
@@ -45,6 +61,8 @@ public class ThreadPoolConfig {
|
|||||||
executor.setKeepAliveSeconds(keepAliveSeconds);
|
executor.setKeepAliveSeconds(keepAliveSeconds);
|
||||||
// 线程池对拒绝任务(无线程可用)的处理策略
|
// 线程池对拒绝任务(无线程可用)的处理策略
|
||||||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||||
|
executor.setThreadNamePrefix(threadNamePrefix);
|
||||||
|
executor.setWaitForTasksToCompleteOnShutdown(true);
|
||||||
// log.info("threadPoolTaskExecutor创建成功");
|
// log.info("threadPoolTaskExecutor创建成功");
|
||||||
return executor;
|
return executor;
|
||||||
}
|
}
|
||||||
@@ -55,12 +73,14 @@ public class ThreadPoolConfig {
|
|||||||
@Bean(name = "thirdpartyTaskExecutor")
|
@Bean(name = "thirdpartyTaskExecutor")
|
||||||
public ThreadPoolTaskExecutor thirdpartyTaskExecutor() {
|
public ThreadPoolTaskExecutor thirdpartyTaskExecutor() {
|
||||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||||
executor.setMaxPoolSize(maxPoolSize/10);
|
executor.setMaxPoolSize(corePoolSize_tp);
|
||||||
executor.setCorePoolSize(corePoolSize/10);
|
executor.setCorePoolSize(maxPoolSize_tp);
|
||||||
executor.setQueueCapacity(queueCapacity/10);
|
executor.setQueueCapacity(queueCapacity_tp);
|
||||||
executor.setKeepAliveSeconds(keepAliveSeconds);
|
executor.setKeepAliveSeconds(keepAliveSeconds_tp);
|
||||||
// 线程池对拒绝任务(无线程可用)的处理策略
|
// 线程池对拒绝任务(无线程可用)的处理策略
|
||||||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.DiscardOldestPolicy());
|
||||||
|
executor.setThreadNamePrefix(threadNamePrefix_tp);
|
||||||
|
executor.setWaitForTasksToCompleteOnShutdown(true);
|
||||||
// log.info("threadPoolTaskExecutor创建成功");
|
// log.info("threadPoolTaskExecutor创建成功");
|
||||||
return executor;
|
return executor;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user