         [compojure.core :only (defroutes ANY POST GET PUT DELETE)]))
 
 (def conman
-  (make-reusable-conn-manager {:timeout 10 :threads 50 :default-per-route 50}))
+  (make-reusable-conn-manager 
+   {:threads 10 :default-per-route 10}))
 
 (def connection
-  (merge {:accept :json}
-         {:throw-exceptions false}
+  (merge {:accept :json
+          :throw-exceptions false
+          :socket-timeout 5000  ;; in milliseconds
+          :conn-timeout 120000}
          {:connection-manager conman}))
 
 (def read-key (-> properties :keen :read-key))

      json/read-str
      walk/keywordize-keys))

(def memo-count-by-id
  (memo/ttl count-by-id :ttl/threshold (* 60 60 1000)))

(defn try-get-one [id]
  (try

      "&event_collection=pageviews&timezone=7200" filters-as-str group-by-str)))

(defn count-by-id [id]
  (try
    (let [filter-by [{:property_name :eid :operator :eq :property_value id}]]
      (-> (http/get (keen-count-uri filter-by nil) connection)
          :body
          json/read-str
          walk/keywordize-keys))
    (catch Exception ex
      (prn ex)
      {:result 0})))

(defn group-by-eid []
  (-> (http/get (keen-count-uri  nil "eid") connection)
