Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Figure out capacity reserve for any app ever
(defn degraded-boxes [degradation-time chef-time sleep-time concurrency]
(* concurrency (Math/ceil
(/ degradation-time
(+ chef-time sleep-time)))))
(defn number-of-boxes [chef-time
sleep-time
tolerable-boxes
degradation-time
concurrency]
(Math/ceil (+ concurrency tolerable-boxes (degraded-boxes degradation-time chef-time sleep-time concurrency))))
(defn target-deploy-time [chef-time sleep-time tolerable-boxes degradation-time concurrency]
(* (+ chef-time sleep-time)
(Math/ceil (/ (number-of-boxes chef-time
sleep-time
tolerable-boxes
degradation-time
concurrency)
concurrency))))
(def chef-time 30)
(def tolerable-boxes 10)
(def degradation-time 300)
(defn target-deploy-time4estimate [sleep-time concurrency]
(* (+ chef-time sleep-time) (Math/ceil
(/ (number-of-boxes chef-time
sleep-time
tolerable-boxes
degradation-time
concurrency)
concurrency))))
(defn total-no-boxes [sleep-time concurrency]
(number-of-boxes chef-time sleep-time tolerable-boxes degradation-time concurrency))
(defn data [BOXES TIME]
(map (fn [y] (concat (map (fn [x]
[(+ (* BOXES (float (total-no-boxes x y)))
(* TIME (float (target-deploy-time4estimate x y))))
(float (total-no-boxes x y))
(float (target-deploy-time4estimate x y))
x
y])
(range 30 1000))))
(range 1 100)))
(defn get-data [BOXES TIME] (clojure.pprint/pprint (map (fn [v] {:weight (v 0)
:boxes (v 1)
:total-time (v 2)
:sleep-time (v 3)
:concurrency (v 4)})
(take 10 (sort-by first < (apply concat (data BOXES TIME)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment