Skip to content

Commit 1dfcc8a

Browse files
authored
Merge pull request #11128 from neinteractiveliterature/medium-instances
Use medium-sized instances during high-scale time periods
2 parents 3487da1 + 742c1a7 commit 1dfcc8a

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

app/services/autoscale_servers_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def inner_call
122122

123123
adapter.apply_instance_counts(
124124
[
125-
{ group: :web, type: :small, count: web_scaling_target },
125+
{ group: :web, type: web_scaling_target == MIN_INSTANCES ? :small : :medium, count: web_scaling_target },
126126
{ group: :worker, type: worker_instance_type, count: worker_scaling_target }
127127
]
128128
)

app/services/hosting_service_adapters/fly.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
class HostingServiceAdapters::Fly < HostingServiceAdapters::Base
22
SMALL_GUEST = { "cpu_kind" => "shared", "cpus" => 1, "memory_mb" => 512 }
3+
MEDIUM_GUEST = { "cpu_kind" => "shared", "cpus" => 4, "memory_mb" => 1024 }
34
LARGE_GUEST = { "cpu_kind" => "performance", "cpus" => 1, "memory_mb" => 2048 }
45

56
class Machine < HostingServiceAdapters::Instance
@@ -62,6 +63,7 @@ def machines_api
6263
builder.request :json
6364
builder.response :json
6465
builder.response :raise_error
66+
builder.response :logger, nil, { headers: true, bodies: true, errors: true }
6567
end
6668
end
6769

@@ -93,6 +95,8 @@ def instance_for_machine(machine) # rubocop:disable Metrics/MethodLength
9395
case guest
9496
when SMALL_GUEST
9597
:small
98+
when MEDIUM_GUEST
99+
:medium
96100
when LARGE_GUEST
97101
:large
98102
else
@@ -105,6 +109,8 @@ def guest_config_for_type(type)
105109
case type
106110
when :small
107111
SMALL_GUEST
112+
when :medium
113+
MEDIUM_GUEST
108114
when :large
109115
LARGE_GUEST
110116
end

app/services/hosting_service_adapters/heroku.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ def instances_state # rubocop:disable Metrics/MethodLength
2121

2222
type =
2323
case dyno_group["dyno_size"]["name"]
24-
when "eco", "basic", "standard-1X"
24+
when "eco", "basic"
2525
:small
26+
when "standard-1X"
27+
:medium
2628
when "standard-2X"
2729
:large
2830
else
@@ -46,9 +48,12 @@ def update_instance_group(group:, type:, count:)
4648
end
4749

4850
dyno_size =
49-
if type == :small
51+
case type
52+
when :small
5053
count == 1 ? "basic" : "standard-1X"
51-
elsif type == :large
54+
when :medium
55+
"standard-1X"
56+
when :largerge
5257
"standard-2X"
5358
end
5459

0 commit comments

Comments
 (0)