cloudfoundry / cloudfoundry/cf-java-client

CF V3 getProcessStatistics - The threads are not released

Aperta
#1,182 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Java
Stelle
334
Fork
319
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

@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)

image

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia dal punto di ingresso applicationsV3().getProcessStatistics ed esamina l’issue 1054 insieme all’utilizzo segnalato di requestAllApplicationStatistics. Poiché nell’issue non sono identificati alcun file del repository né alcun test, individua prima l’implementazione e i test esistenti, quindi riproduci le chiamate ripetute. Il completamento deve essere dimostrato da un test di regressione che mostri che il numero di thread non continua ad aumentare dopo il completamento delle richieste di statistiche.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
api
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
30/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.