Class: Aws::RailsProvisioner::Scaling

Inherits:
Object
  • Object
show all
Defined in:
lib/aws-rails-provisioner/scaling.rb

Defined Under Namespace

Classes: BaseScaling, MetricScaling, ScheduleScaling

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Scaling

Configuration for Fargate service scaling

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :max_capacity (required, Integer)

    maximum capacity to scale to

  • :min_capacity (Integer)

    minimum capacity to scale to default to 1

  • :on_cpu (Hash)

    scale out or in to achieve a target CPU utilization @example: at `aws-rails-provisioner.yml`

    scaling:
      on_cpu:
        target_util_percent: 80
        scale_in_cool_down: 300
    

    @see BaseScaling

  • :on_memory (Hash)

    scale out or in to achieve a target memory utilization @example: at `aws-rails-provisioner.yml`

    scaling:
      on_memory:
        target_util_percent: 80
        scale_out_cool_down: 200
    

    @see BaseScaling

  • :on_metric (Hash)

    scale out or in based on a metric value @example: at `aws-rails-provisioner.yml`

    on_metric:
      adjustment_type: percentchangeincapacity
      min_adjustment_magnitude: 10
      cooldown: 300
      metric:
        name: foo
    

    @see MetricScaling

  • :on_custom_metric (Hash)

    scale out or in to track a custom metric @example: at `aws-rails-provisioner.yml`

    scaling:
      on_custom_metric:
        target_value: 100
        scale_in_cooldown: 300
        scale_out_cooldown: 500
        metric:
          name: foo
    

    @see MetricScaling

  • :on_request (Hash)

    scale out or in to achieve a target ALB request count per target @example: at `aws-rails-provisioner.yml`

    scaling:
      on_request:
        requests_per_target: 100000
        disable_scale_in: true
    

    @see BaseScaling

  • :on_schedule (Hash)

    scale out or in based on time @example: at `aws-rails-provisioner.yml`

    scaling:
      on_schedule:
        schedule: 'at(yyyy-mm-ddThh:mm:ss)'
        max_capacity: 10
        min_capacity: 5
    

    @see ScheduleScaling



71
72
73
74
75
76
77
78
79
80
81
# File 'lib/aws-rails-provisioner/scaling.rb', line 71

def initialize(options = {})
  @max_capacity = options.fetch(:max_capacity)
  @min_capacity = options[:min_capacity]

  @on_cpu = _scaling_props(:cpu, options[:cpu])
  @on_memory = _scaling_props(:memory, options[:memory])
  @on_metric = _scaling_props(:metric, options[:metric])
  @on_request = _scaling_props(:request, options[:request])
  @on_schedule = _scaling_props(:schedule, options[:schedule])
  @to_track_custome_metric = _scaling_props(:custom, options[:custom_metric])
end

Instance Attribute Details

#max_capacityInteger (readonly)

Returns:

  • (Integer)


84
85
86
# File 'lib/aws-rails-provisioner/scaling.rb', line 84

def max_capacity
  @max_capacity
end

#min_capacityInteger (readonly)

Returns:

  • (Integer)


87
88
89
# File 'lib/aws-rails-provisioner/scaling.rb', line 87

def min_capacity
  @min_capacity
end

#on_cpuBaseScaling (readonly)

Returns:



90
91
92
# File 'lib/aws-rails-provisioner/scaling.rb', line 90

def on_cpu
  @on_cpu
end

#on_memoryBaseScaling (readonly)

Returns:



93
94
95
# File 'lib/aws-rails-provisioner/scaling.rb', line 93

def on_memory
  @on_memory
end

#on_metricMetricScaling (readonly)

Returns:



99
100
101
# File 'lib/aws-rails-provisioner/scaling.rb', line 99

def on_metric
  @on_metric
end

#on_requestBaseScaling (readonly)

Returns:



96
97
98
# File 'lib/aws-rails-provisioner/scaling.rb', line 96

def on_request
  @on_request
end

#on_scheduleScheduleScaling (readonly)

Returns:



105
106
107
# File 'lib/aws-rails-provisioner/scaling.rb', line 105

def on_schedule
  @on_schedule
end

#to_track_custom_metricMetricScaling (readonly)

Returns:



102
103
104
# File 'lib/aws-rails-provisioner/scaling.rb', line 102

def to_track_custom_metric
  @to_track_custom_metric
end