|
1 | | -# Script to generate graph: |
2 | | -# require "csv" |
3 | | -# Time.zone = "America/New_York" |
4 | | -# time = Time.local(2022, 10, 31) |
5 | | -# data = [] |
6 | | -# while time < Time.local(2022, 11, 4) |
7 | | -# data << [time, AutoscaleServersService.scaling_target_for(time)] |
8 | | -# time += 15.minutes |
9 | | -# end |
10 | | -# CSV.open("scaling-graph.csv", "w") do |csv| |
11 | | -# csv << %w[Time Servers] |
12 | | -# data.each { |row| csv << row } |
13 | | -# end |
| 1 | +# To simulate the effect of autoscaling as a CSV file: |
| 2 | +# bin/rails runner script/generate_simulated_autoscaling_graph.rb |
14 | 3 |
|
15 | 4 | class AutoscaleServersService < CivilService::Service |
16 | 5 | USERS_PER_INSTANCE = ENV.fetch("AUTOSCALE_USERS_PER_INSTANCE", "40").to_i |
17 | | - MIN_INSTANCES = ENV.fetch("AUTOSCALE_MIN_INSTANCES", "1").to_i |
| 6 | + MIN_INSTANCES = ENV.fetch("AUTOSCALE_MIN_INSTANCES", "2").to_i |
18 | 7 | MIN_INSTANCES_FOR_SIGNUP_OPENING = ENV.fetch("AUTOSCALE_MIN_INSTANCES_FOR_SIGNUP_OPENING", "2").to_i |
19 | | - MAX_INSTANCES = ENV.fetch("AUTOSCALE_MAX_INSTANCES", "8").to_i |
| 8 | + MAX_INSTANCES = ENV.fetch("AUTOSCALE_MAX_INSTANCES", "10").to_i |
20 | 9 | SIGNUP_OPENING_LOOKAHEAD_TIME = ENV.fetch("AUTOSCALE_SIGNUP_OPENING_LOOKAHEAD_HOURS", "48").to_i.hours |
21 | 10 | SIGNUP_OPENING_RAMP_UP_LOOKAHEAD_TIME = ENV.fetch("AUTOSCALE_SIGNUP_OPENING_RAMP_UP_LOOKAHEAD_HOURS", "2").to_i.hours |
22 | 11 | SIGNUP_OPENING_FULL_THROTTLE_LOOKAHEAD_TIME = |
23 | 12 | ENV.fetch("AUTOSCALE_SIGNUP_OPENING_FULL_THROTTLE_LOOKAHEAD_HOURS", "1").to_i.hours |
24 | | - SIGNUP_OPENING_DECAY_TIME = ENV.fetch("AUTOSCALE_SIGNUP_OPENING_DECAY_TIME", "1").to_i.hours |
| 13 | + SIGNUP_OPENING_DECAY_TIME = ENV.fetch("AUTOSCALE_SIGNUP_OPENING_DECAY_TIME", "6").to_i.hours |
25 | 14 | SIGNUP_OPENING_LOOKBACK_TIME = ENV.fetch("AUTOSCALE_SIGNUP_OPENING_LOOKBACK_TIME", "6").to_i.hours |
26 | 15 |
|
27 | 16 | def self.scaling_target_for_signup_opening(convention) |
|
0 commit comments