Skip to content

Commit

Permalink
[backend] adjust the thread pool size with the numbers of the CPU (#1625
Browse files Browse the repository at this point in the history
)

* [backend] adjust the thread pool size with the numbers of the CPU

* [backend] 2x size for the pool

* [backend]ignore Vulnerability
  • Loading branch information
guzhongren authored Nov 5, 2024
1 parent 510a452 commit ebff22c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions .trivyignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ CVE-2024-45490
CVE-2024-45491
CVE-2024-45492
CVE-2024-47554
CVE-2023-49462
9 changes: 7 additions & 2 deletions backend/src/main/java/heartbeat/config/ThreadPoolConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ public class ThreadPoolConfig {
public ThreadPoolTaskExecutor taskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
executor.setCorePoolSize(20);
executor.setMaxPoolSize(100);
int numOfCores = Runtime.getRuntime().availableProcessors();

int corePoolSize = numOfCores * 2;
int maxPoolSize = corePoolSize * 2;

executor.setCorePoolSize(corePoolSize);
executor.setMaxPoolSize(maxPoolSize);
executor.setQueueCapacity(1000);
executor.setKeepAliveSeconds(60);
executor.setThreadNamePrefix("Heartbeat-");
Expand Down

0 comments on commit ebff22c

Please sign in to comment.