protected Server configureJettyThreadPool(int acceptorThreads,
      String threadPoolName, int configuredThreadPoolSize) {
    int minumumAvailableThreads = 20;

    // multiply by two since there is 1 selector for every acceptor
    int reservedJettyThreads = acceptorThreads * 2;

    // this is the calculation used by Jetty
    if (configuredThreadPoolSize < reservedJettyThreads + minumumAvailableThreads) {
      int newThreadPoolSize = reservedJettyThreads + minumumAvailableThreads;

      LOG.warn(
          "The configured Jetty {} thread pool value of {} is not sufficient on a host with {} processors. Increasing the value to {}.",
          threadPoolName, configuredThreadPoolSize, Runtime.getRuntime().availableProcessors(),
          newThreadPoolSize);

      configuredThreadPoolSize = newThreadPoolSize;
    }

    LOG.info(
      "Jetty is configuring {} with {} reserved acceptors/selectors and a total pool size of {} for {} processors.",
      threadPoolName, acceptorThreads * 2, configuredThreadPoolSize,
      Runtime.getRuntime().availableProcessors());

    QueuedThreadPool qtp = new QueuedThreadPool(configuredThreadPoolSize);
    qtp.setName(threadPoolName);
    return new Server(qtp);
  }
The Jetty thread pool consists of three basic types of threads:
<ul>
<li>Acceptors</li>
<li>Selectors</li>
<li>Threads which can actually do stuff</li>
<ul>
The {@link SelectChannelConnector} uses the
{@link Runtime#availableProcessors()} as a way to determine how many
acceptors and selectors to create. If the number of processors is too
great, then there will be no threads left to fullfil connection requests.
This method ensures that the pool size is configured correctly, taking into
account the number of available processors (sockets x core x
threads-per-core).
<p/>
If the configured pool size is determined to be too small, then this will
log a warning and increase the pool size to ensure that there are at least
20 available threads for requests.

@param acceptorThreads
         the number of Acceptor threads configured for the connector.
@param threadPoolName
         the name of the thread pool being configured (not {@code null}).
@param configuredThreadPoolSize
         the size of the pool from {@link Configuration}.
ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java