TilesController with separate threadpool
With the increased use of the Subsetting Tool, the API gets hit with tons of /acn/tile...
requests.
I'd like to process the requests for tile images using @Async
in TileController
and a separate thread pool that will process 5 requests in parallel and reject new requests if the queue is already full. Something like:
@Bean(name = "tileGeneratorPool", destroyMethod = "shutdown")
public ThreadPoolTaskExecutor tileGeneratorPool() {
final ThreadPoolTaskExecutor pool = new ThreadPoolTaskExecutor();
pool.setCorePoolSize(1);
pool.setMaxPoolSize(5);
pool.setQueueCapacity(200);
pool.setThreadPriority(Thread.MIN_PRIORITY);
pool.setThreadNamePrefix("genesys-tile-");
pool.setRejectedExecutionHandler((Runnable r, ThreadPoolExecutor e) -> {
throw new RejectedExecutionException("Tile generator queue is full");
});
return pool;
}