cloudfoundry / cloudfoundry/cf-java-client
CF V3 getProcessStatistics - The threads are not released
まだ誰も着手していません。
- 主要言語
- Java
- スター
- 334
- フォーク
- 319
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
@twoseat I am tagging you directly as the issue still exists.
we have about 70 microservices running in the cloud foundry & we would like to monitor all the microservices with the following metrics,
- State
- Memory utilization
- CPU Utilization
- Disk Utilization
recently, I started to use CF v3 API & the issue is still the same. The allocated threads are not released, Due to which the application crashes multiple times a day.
The below API is called once every 5 minutes for about 70+ microservices
public void requestAllApplicationStatistics(DefaultCloudFoundryOperations cloudFoundryOperations, List<CfArtifacts> cfArtifacts) {
initializeTaskExecutor();
Flux.fromIterable(cfArtifacts)
.flatMap(application -> cloudFoundryOperations.getCloudFoundryClient().applicationsV3()
.getProcessStatistics(GetApplicationProcessStatisticsRequest.builder()
.applicationId(application.getId())
.type("web")
.build())
.map(response -> {
logger.debug("step 1 - cfStatistics fetched successfully");
CfApplicationResponse cfApplicationResponse = new CfApplicationResponse();
cfApplicationResponse.setApplicationId(application.getName());
cfApplicationResponse.setCfApplicationId(application.getId());
cfApplicationResponse.setPrefix(application.getPrefix());
List<ProcessStatisticsResource> resourceList = response.getResources();
cfApplicationResponse.setApplicationInstances(resourceList);
logger.debug("step 2 - cfStatistics before calling the callback");
return cfApplicationResponse;
})
.doOnError(e -> {
logger.error("cfStatistics Fetch Failed with error: {}", e.getMessage(), e);
})
.doFinally(signalType -> {
logger.debug("All applications processed. Shutting down the executor service.");
// shutdownTaskExecutor(); // Shutdown the executor service
})
)
.subscribeOn(Schedulers.fromExecutor(taskExecutor))// Use the shared task executor
.publishOn(Schedulers.fromExecutor(taskExecutor)) // Use the shared task executor
.doOnNext(cfResponseCallback::processCfMetrics)
.subscribe(); // Subscribe to start the execution
}
private static synchronized void initializeTaskExecutor() {
if (taskExecutor == null) {
taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setCorePoolSize(10); // Set the desired core pool size
taskExecutor.setMaxPoolSize(20); // Set the desired maximum pool size
taskExecutor.setThreadNamePrefix("cf-task-executor-"); // Set a thread name prefix
taskExecutor.initialize(); // Initialize the task executor
}
}
Look at the active threads in the below screenshot, it keeps increasing & crashes (the screenshot was captured from the Health Monitoring on the total threads measured by java Open telemetry instrumentation)
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
エントリポイント applicationsV3().getProcessStatistics から始め、報告されている requestAllApplicationStatistics の使用状況と合わせて issue 1054 を確認してください。issue ではリポジトリのファイルやテストが特定されていないため、まず実装と既存のテストを見つけ、その後、繰り返し呼び出しを再現してください。完了は、統計リクエストの完了後にスレッド数が増え続けないことを示す回帰テストによって実証する必要があります。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- java
- 領域
- api
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 30/100