AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Class: Aws::RailsProvisioner::Scaling::MetricScaling

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

Defined Under Namespace

Classes: Metric, ScalingInterval

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, options) ⇒ MetricScaling

Configuration for metric scaling policy

Parameters:

  • options (Hash)

Options Hash (options):

  • :adjustment_type (String)

    how the adjustment numbers inside 'intervals' are interpreted, available for `:on_metric`, supporting types: `change_in_capacity`, `percent_change_in_capacity` or `exact_capacity`

  • :min_adjustment_magnitude (Integer)

    available for `:on_metric`, when :adjustment_type set to `percentchangeincapacity` minimum absolute number to adjust capacity with as result of percentage scaling.

  • :cooldown (Integer)

    grace period after scaling activity in seconds, available for `:on_metric`

  • :scaling_steps (Array<ScalingInterval>)

    intervals for scaling, array of Aws::RailsProvisioner::Scaling::MetricScaling::ScalingInterval, available for `:on_metric` @example: at `aws-rails-provisioner.yml`

    on_metric:
      scaling_steps:
        -
          change: 10
          lower: 30
          upper: 60
        -
          change: 20
          lower: 0
          upper: 20
    

    @see ScalingInterval

  • :metric (Hash)

    @example: at `aws-rails-provisioner.yml`

    on_metric:
      metric:
        name: foo
        namespace: bar
        dimensions:
          key:value
    on_custom_metric:
      metric:
        name: baz
    

    @see Metric

  • :target_value (Integer)

    the target value to achieve for the metric available for :custom_metric

  • :disable_scale_in (Boolean)

    whether scale in by the target tracking policy is disabled, available for :custom_metric

  • :scale_in_cooldown (Integer)

    period (in seconds) after a scale in activity completes before another scale in activity can start, available for :custom_metric

  • :scale_out_cooldown (Integer)

    period (in seconds) after a scale out activity completes before another scale out activity can start, available for :custom_metric



181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/aws-rails-provisioner/scaling.rb', line 181

def initialize(type, options)
  @metric = Metric.new(type, options)
  if type == :custom
    @target_value = options[:target_value]
    @disable_scale_in = !!options[:disable_scale_in]
    @scale_in_cooldown = options[:scale_in_cooldown]
    @scale_out_cooldown = options[:scale_out_cooldown]
  else # :metric
    @scaling_steps = _scaling_steps(options[:scaling_steps] || [])
    @cooldown_sec = options[:cooldown]
    @adjustment_type = Aws::RailsProvisioner::Utils.adjustment_type(
      options[:adjustment_type]) if options[:adjustment_type]
    if @adjustment_type == 'PercentChangeInCapacity'
      @min_adjustment_magnitude = options[:min_adjustment_magnitude]
    end
  end
end

Instance Attribute Details

#adjustment_typeString (readonly)

Returns:

  • (String)


218
219
220
# File 'lib/aws-rails-provisioner/scaling.rb', line 218

def adjustment_type
  @adjustment_type
end

#cooldown_secInteger (readonly)

Returns:

  • (Integer)


221
222
223
# File 'lib/aws-rails-provisioner/scaling.rb', line 221

def cooldown_sec
  @cooldown_sec
end

#disable_scale_inBoolean (readonly)

Returns:

  • (Boolean)


206
207
208
# File 'lib/aws-rails-provisioner/scaling.rb', line 206

def disable_scale_in
  @disable_scale_in
end

#metricMetric (readonly)

Returns:



200
201
202
# File 'lib/aws-rails-provisioner/scaling.rb', line 200

def metric
  @metric
end

#min_adjustment_magnitudeInteger (readonly)

Returns:

  • (Integer)


224
225
226
# File 'lib/aws-rails-provisioner/scaling.rb', line 224

def min_adjustment_magnitude
  @min_adjustment_magnitude
end

#scale_in_cooldownInteger (readonly)

Returns:

  • (Integer)


209
210
211
# File 'lib/aws-rails-provisioner/scaling.rb', line 209

def scale_in_cooldown
  @scale_in_cooldown
end

#scale_out_cooldownInteger (readonly)

Returns:

  • (Integer)


212
213
214
# File 'lib/aws-rails-provisioner/scaling.rb', line 212

def scale_out_cooldown
  @scale_out_cooldown
end

#scaling_stepsArray<ScalingInterval> (readonly)

Returns:



215
216
217
# File 'lib/aws-rails-provisioner/scaling.rb', line 215

def scaling_steps
  @scaling_steps
end

#target_valueInteger (readonly)

Returns:

  • (Integer)


203
204
205
# File 'lib/aws-rails-provisioner/scaling.rb', line 203

def target_value
  @target_value
end

Instance Method Details

#scaling_steps?Boolean

Returns:

  • (Boolean)


331
332
333
# File 'lib/aws-rails-provisioner/scaling.rb', line 331

def scaling_steps?
  @scaling_steps && !@scaling_steps.empty?
end