            ["/json" json-handler]
            ["/db" (blocking (db-handler ds))]])
         (ring/create-default-handler)
-        {:inject-match? false, :inject-router? false})
+        {:inject-match? false
+         :inject-router? false})
       {:port 8080
        :host "0.0.0.0"
+       :io-threads (* 2 (.availableProcessors (Runtime/getRuntime)))
        :dispatch? false
-       :worker-threads 64
+       :worker-threads 48
        :server {:always-set-keep-alive false}})))
 
 (comment

(defn -main [& _]
  (let [ds (hikari/make-datasource
             {:read-only true
              :maximum-pool-size 64
              :pool-name "db-pool"
              :adapter "postgresql"
              :username "benchmarkdbuser"


(defn blocking [handler]
  (fn [req]
    (let [exchange ^HttpServerExchange (:server-exchange req)]
      (if (.isInIoThread exchange)
        (.dispatch exchange ^Runnable ^:once (fn []
                                               (.startBlocking exchange)
                                               (immutant/write-response exchange (handler req))
                                               (.endExchange exchange)))
        (handler req)))))

(defn random []
  (unchecked-inc (.nextInt (ThreadLocalRandom/current) 10000)))
