瀏覽代碼

Update reitit JVM-settings (#4762)

Tommi Reiman 6 年之前
父節點
當前提交
c17992a739
共有 1 個文件被更改,包括 9 次插入11 次删除
  1. 9 11
      frameworks/Clojure/reitit/src/hello/handler.clj

+ 9 - 11
frameworks/Clojure/reitit/src/hello/handler.clj

@@ -13,10 +13,10 @@
   (fn [req]
   (fn [req]
     (let [exchange ^HttpServerExchange (:server-exchange req)]
     (let [exchange ^HttpServerExchange (:server-exchange req)]
       (if (.isInIoThread exchange)
       (if (.isInIoThread exchange)
-        (.dispatch exchange ^Runnable ^:once (fn []
-                                               (.startBlocking exchange)
-                                               (immutant/write-response exchange (handler req))
-                                               (.endExchange exchange)))
+        (.dispatch exchange ^Runnable (^:once fn* []
+                                        (.startBlocking exchange)
+                                        (immutant/write-response exchange (handler req))
+                                        (.endExchange exchange)))
         (handler req)))))
         (handler req)))))
 
 
 (defn random []
 (defn random []
@@ -25,7 +25,7 @@
 (def query-one (:query-one (p/compile {:row (p/rs->compiled-record)})))
 (def query-one (:query-one (p/compile {:row (p/rs->compiled-record)})))
 
 
 (defn random-world [ds]
 (defn random-world [ds]
-  (with-open [con (p/get-connection ds)]
+  (let [con (p/get-connection ds)]
     (query-one con ["SELECT id, randomnumber from WORLD where id=?" (random)])))
     (query-one con ["SELECT id, randomnumber from WORLD where id=?" (random)])))
 
 
 (defn plain-text-handler [_]
 (defn plain-text-handler [_]
@@ -46,16 +46,14 @@
 
 
 (defn -main [& _]
 (defn -main [& _]
   (let [ds (hikari/make-datasource
   (let [ds (hikari/make-datasource
-             {:read-only true
-              :maximum-pool-size 48
+             {:maximum-pool-size 256
               :pool-name "db-pool"
               :pool-name "db-pool"
               :adapter "postgresql"
               :adapter "postgresql"
               :username "benchmarkdbuser"
               :username "benchmarkdbuser"
               :password "benchmarkdbpass"
               :password "benchmarkdbpass"
               :database-name "hello_world"
               :database-name "hello_world"
               :server-name "tfb-database"
               :server-name "tfb-database"
-              :port-number 5432
-              :register-mbeans false})]
+              :port-number 5432})]
     (web/run
     (web/run
       (ring/ring-handler
       (ring/ring-handler
         (ring/router
         (ring/router
@@ -67,9 +65,9 @@
          :inject-router? false})
          :inject-router? false})
       {:port 8080
       {:port 8080
        :host "0.0.0.0"
        :host "0.0.0.0"
-       :io-threads (* 2 (.availableProcessors (Runtime/getRuntime)))
        :dispatch? false
        :dispatch? false
-       :worker-threads 48
+       :io-threads (* 2 (.availableProcessors (Runtime/getRuntime)))
+       :worker-threads (* 8 (.availableProcessors (Runtime/getRuntime)))
        :server {:always-set-keep-alive false}})))
        :server {:always-set-keep-alive false}})))
 
 
 (comment
 (comment