Created
November 21, 2018 06:15
-
-
Save kitallis/f8647bfd1e0ec7b15b14f3c36c8735a6 to your computer and use it in GitHub Desktop.
Figure out capacity reserve for any app ever
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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