title: How to decide on the ThreadPoolTaskExecutor pools and queue sizes?
body: <p>This is may be more general question, on how to decide on the thread pool size, but let's use the Spring <code>ThreadPoolTaskExecutor</code> for this case. I have the following configuration for the pool core and max size and the queue capacity. I've already read about what all these configurations mean - there is a good answer <a href="https://stackoverflow.com/questions/17659510/core-pool-size-vs-maximum-pool-size-in-threadpoolexecutor">here</a>.</p>
  
  <pre><code>    @SpringBootApplication
      @EnableAsync
      public class MySpringBootApp {
  
          public static void main(String[] args) {
              ApplicationContext ctx = SpringApplication.run(MySpringBootApp.class, args);
          }
  
          @Bean
          public TaskExecutor taskExecutor() {
              ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
              executor.setCorePoolSize(5);
              executor.setMaxPoolSize(10);
              executor.setQueueCapacity(25);
              return executor;
          }
  
      }
  </code></pre>
  
  <p>The above numbers look random to me and I want to understand how to set them up correctly based on my environment. I will outline the following constraints that I have:</p>
  
  <ol>
  <li>the application will be running on a two-core CPU box</li>
  <li>the executor will work on a task which usually takes about 1-2
  seconds to finish.</li>
  <li>Usually I expect 800/min tasks to be submitted to my executor, spiking at 2500/min</li>
  <li>The task will construct some objects and make an HTTP call to Google pubsub.</li>
  </ol>
  
  <p>Ideally I'd like to understand what other constraints I need to consider and based on them what will be a reasonable configuration for my pools and queue sizes.</p>