                                  (get-server-thread-pool-queue server)))
         "Unexpected default for 'queue-max-size'")))
 
-(def threads-per-connector
+(defn required-threads-for-sized-threadpool
+  [threadpool-size]
   "The total number of threads needed per attached connector."
-  (+ acceptor-thread-count selector-thread-count))
+  (+ (reserved-thread-count threadpool-size)
+     (selector-thread-count threadpool-size)
+     acceptor-thread-count))
 
 (defn calculate-minimum-required-threads
-  "Calculate the minimum number threads that a single Jetty Server instance
-  needs.  See: https://github.com/eclipse/jetty.project/blob/jetty-9.4.1.v20170120/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java#L384-L414"
-  [connectors]
-  (+ 1 (* connectors threads-per-connector)))
+  "Jetty calculates the minimum number of required threads based on the the
+  size of the machine it runs on and the number of threads in its thread pool.
+  The smaller we shrink the thread pool the fewer threads it will request.
+  This logic doesn't scale as the thread pool grows beyond 10 threads but
+  allows us to come up with a number that works for the max threads that isn't
+  self referential."
+  [num-connectors]
+  (+ 2 (* num-connectors 2)))
 
 (deftest default-min-threads-settings-test
   ;; This test just exists to validate the advice we give for the bare

          "Unexpected default for proxy 'idle-timeout'")
      (.stop client))))

(def selector-thread-count
  "The number of selector threads that should be allocated per connector.  See:
   https://github.com/eclipse/jetty.project/blob/jetty-9.4.1.v20170120/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java#L223
   and
   https://github.com/eclipse/jetty.project/blob/jetty-9.4.1.v20170120/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java#L403-L408
   The number of selectors is twice the number of selector threads."
  (* 2 (max 1 (min 4 (int (/ (ks/num-cpus) 2))))))

(def acceptor-thread-count
  "The number of acceptor threads that should be allocated per connector.  See:
   https://github.com/eclipse/jetty.project/blob/jetty-9.4.1.v20170120/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractConnector.java#L194"
  (max 1 (min 4 (int (/ (ks/num-cpus) 8)))))

(deftest default-connector-settings-test
  (let [connector (ServerConnector. (Server.))]

        "Unexpected default for 'idle-timeout-milliseconds'")
    (is (= acceptor-thread-count (.getAcceptors connector))
        "Unexpected default for 'acceptor-threads' and 'ssl-acceptor-threads'")
    (is (= (selector-thread-count (-> connector .getExecutor .getMaxThreads))
           (.getSelectorCount (.getSelectorManager connector)))
        "Unexpected default for 'selector-threads' and 'ssl-selector-threads'")))

(defn get-max-threads-for-server
