parallelize regular trip detection for massively improved performance
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good

This commit is contained in:
2026-02-09 14:30:32 +01:00
parent f7d7f6bc53
commit b95355c10f
5 changed files with 113 additions and 21 deletions
@@ -0,0 +1,39 @@
package SuMoC.backend.config;
import SuMoC.backend.suggestion.config.RegularTripSuggestionProperties;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
@Configuration
@EnableAsync
@RequiredArgsConstructor
public class AsyncConfiguration {
private final RegularTripSuggestionProperties regularTripSuggestionProperties;
/**
* Custom thread pool executor for parallel processing of regular trip suggestions.
* Configured with parallelism setting from application properties.
*/
@Bean(name = "regularTripSuggestionExecutor")
public Executor regularTripSuggestionExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
int parallelism = regularTripSuggestionProperties.getParallelism();
executor.setCorePoolSize(parallelism);
executor.setMaxPoolSize(parallelism);
executor.setQueueCapacity(500); // Queue capacity for pending tasks
executor.setThreadNamePrefix("regular-trip-");
executor.setWaitForTasksToCompleteOnShutdown(true);
executor.setAwaitTerminationSeconds(60);
executor.initialize();
return executor;
}
}