Skip to content

Commit

Permalink
add upper/lower alarm thresholds
Browse files Browse the repository at this point in the history
  • Loading branch information
Jofen committed May 22, 2014
1 parent d437e1b commit a5ebcb8
Show file tree
Hide file tree
Showing 8 changed files with 198 additions and 96 deletions.
16 changes: 10 additions & 6 deletions docs/configuration_options.rst
Expand Up @@ -44,8 +44,10 @@ Important note: The table name is treated as a regular expression. That means th
========================================== ==== ==========================================
Option Type Comment
========================================== ==== ==========================================
reads-alarm-threshold int How many percent of the reads capacity should be used before trigging the throughput alarm?
writes-alarm-threshold int How many percent of the writes capacity should be used before trigging the throughput alarm?
reads-upper-alarm-threshold int How many percent of the reads capacity should be used before trigging the high throughput alarm?
reads-lower-alarm-threshold int How many percent of the reads capacity should be used before trigging the low throughput alarm?
writes-upper-alarm-threshold int How many percent of the writes capacity should be used before trigging the high throughput alarm?
writes-lower-alarm-threshold int How many percent of the writes capacity should be used before trigging the low throughput alarm?
enable-reads-autoscaling bool Turn on or off autoscaling of read capacity. Default is ``true``
enable-writes-autoscaling bool Turn on or off autoscaling of write capacity. Default is ``true``
reads-upper-threshold int How many percent of the table capacity should be used before Dynamic DynamoDB scales up the read provisioning?
Expand All @@ -72,7 +74,7 @@ num-read-checks-reset-percent int Set a read consumption percentag
num-write-checks-reset-percent int Set a write consumption percentage when the `num-write-checks-before-scale-down` count should be reset. This option is optional, even if you use the `num-write-checks-before-scale-down` feature
maintenance-windows str Force Dynamic DynamoDB to operate within maintenance windows. E.g. ``22:00-23:59,00:00-06:00``
sns-topic-arn str Full Topic ARN to use for sending SNS notifications
sns-message-types str Comma separated list of message types to receive SNS notifications for. Supported types are ``scale-up``, ``scale-down`` and ``throughput-alarm``
sns-message-types str Comma separated list of message types to receive SNS notifications for. Supported types are ``scale-up``, ``scale-down``, ``high-throughput-alarm``, ``low-throughput-alarm``
allow-scaling-down-reads-on-0-percent bool Allow down scaling of read units when 0% is used.
allow-scaling-down-writes-on-0-percent bool Allow down scaling of write units when 0% is used.
always-decrease-rw-together bool Restrict scale down to only happen when both reads AND writes are in need of scaling down. Set this to ``true`` to minimize down scaling.
Expand All @@ -90,8 +92,10 @@ The ``table:`` section after ``gsi:`` **must** match with an existing ``table:``
========================================== ==== ==========================================
Option Type Comment
========================================== ==== ==========================================
reads-alarm-threshold int How many percent of the reads capacity should be used before trigging the throughput alarm?
writes-alarm-threshold int How many percent of the writes capacity should be used before trigging the throughput alarm?
reads-upper-alarm-threshold int How many percent of the reads capacity should be used before trigging the high throughput alarm?
reads-lower-alarm-threshold int How many percent of the reads capacity should be used before trigging the low throughput alarm?
writes-upper-alarm-threshold int How many percent of the writes capacity should be used before trigging the high throughput alarm?
writes-lower-alarm-threshold int How many percent of the writes capacity should be used before trigging the low throughput alarm?
enable-reads-autoscaling bool Turn on or off autoscaling of read capacity. Default is ``true``
enable-writes-autoscaling bool Turn on or off autoscaling of write capacity. Default is ``true``
reads-upper-threshold int How many percent of the table capacity should be used before Dynamic DynamoDB scales up the read provisioning?
Expand All @@ -118,7 +122,7 @@ num-read-checks-reset-percent int Set a read consumption percentag
num-write-checks-reset-percent int Set a write consumption percentage when the `num-write-checks-before-scale-down` count should be reset. This option is optional, even if you use the `num-write-checks-before-scale-down` feature
maintenance-windows str Force Dynamic DynamoDB to operate within maintenance windows. E.g. ``22:00-23:59,00:00-06:00``
sns-topic-arn str Full Topic ARN to use for sending SNS notifications
sns-message-types str Comma separated list of message types to receive SNS notifications for. Supported types are ``scale-up`` , ``scale-down`` and ``throughput-alarm``
sns-message-types str Comma separated list of message types to receive SNS notifications for. Supported types are ``scale-up`` , ``scale-down``, ``high-throughput-alarm``, ``low-throughput-alarm``
allow-scaling-down-reads-on-0-percent bool Allow down scaling of read units when 0% is used.
allow-scaling-down-writes-on-0-percent bool Allow down scaling of write units when 0% is used.
always-decrease-rw-together bool Restrict scale down to only happen when both reads AND writes are in need of scaling down. Set this to ``true`` to minimize down scaling.
Expand Down
38 changes: 22 additions & 16 deletions docs/example_configuration.rst
Expand Up @@ -43,13 +43,14 @@ This is a full example of a Dynamic DynamoDB configuration file.
#
# Thresholds for trigging throughput alarm to send notification (%)
# reads-alarm-threshold: 90
# reads-upper-alarm-threshold: 0
# reads-lower-alarm-threshold: 0

# Enable or disable reads autoscaling
enable-reads-autoscaling = true

# Thresholds for scaling up or down the provisioning (%)
reads-upper-threshold: 70
reads-upper-threshold: 90
reads-lower-threshold: 30

# How many percent should Dynamic DynamoDB increase/decrease provisioning with (%)
Expand All @@ -70,13 +71,14 @@ This is a full example of a Dynamic DynamoDB configuration file.
#

# Threshold for trigging throughput alarm to send notification (%)
# writes-alarm-threshold: 90
# writes-upper-alarm-threshold: 0
# writes-lower-alarm-threshold: 0

# Enable or disable writes autoscaling
enable-writes-autoscaling = true

# Thresholds for scaling up or down the provisioning (%)
writes-upper-threshold: 70
writes-upper-threshold: 90
writes-lower-threshold: 30

# How many percent should Dynamic DynamoDB increase/decrease provisioning with (%)
Expand Down Expand Up @@ -109,12 +111,13 @@ This is a full example of a Dynamic DynamoDB configuration file.
# Message types to send as SNS notifications
#
# Comma separated list. Currently supported values:
# - scale-up Get notifications when the table is scaled up
# - scale-down Get notifications when the table is scaled down
# - throughput-alarm Get notifications when exceed alarm threshold
# - scale-up Get notifications when the table is scaled up
# - scale-down Get notifications when the table is scaled down
# - high-throughput-alarm Get notifications when exceed high throughput threshold
# - low-throughput-alarm Get notifications when below low throughput threshold
#
# Example:
# sns-message-types: scale-up, scale-down, throughput-alarm
# sns-message-types: scale-up, scale-down, high-throughput-alarm, low-throughput-alarm

#
# Other settings
Expand All @@ -134,13 +137,14 @@ This is a full example of a Dynamic DynamoDB configuration file.
#

# Thresholds for trigging throughput alarm to send notification (%)
# reads-alarm-threshold: 90
# reads-upper-alarm-threshold: 0
# reads-lower-alarm-threshold: 0

# Enable or disable reads autoscaling
enable-reads-autoscaling = true

# Thresholds for scaling up or down the provisioning (%)
reads-upper-threshold: 70
reads-upper-threshold: 90
reads-lower-threshold: 30

# How many percent should Dynamic DynamoDB increase/decrease provisioning with (%)
Expand All @@ -161,13 +165,14 @@ This is a full example of a Dynamic DynamoDB configuration file.
#

# Threshold for trigging throughput alarm to send notification (%)
# writes-alarm-threshold: 90
# writes-upper-alarm-threshold: 0
# writes-lower-alarm-threshold: 0

# Enable or disable writes autoscaling
enable-writes-autoscaling = true

# Thresholds for scaling up or down the provisioning (%)
writes-upper-threshold: 70
writes-upper-threshold: 90
writes-lower-threshold: 30

# How many percent should Dynamic DynamoDB increase/decrease provisioning with (%)
Expand Down Expand Up @@ -200,12 +205,13 @@ This is a full example of a Dynamic DynamoDB configuration file.
# Message types to send as SNS notifications
#
# Comma separated list. Currently supported values:
# - scale-up Get notifications when the table is scaled up
# - scale-down Get notifications when the table is scaled
# - throughput-alarm Get notifications when exceed alarm threshold
# - scale-up Get notifications when the table is scaled up
# - scale-down Get notifications when the table is scaled
# - high-throughput-alarm Get notifications when exceed high throughput threshold
# - low-throughput-alarm Get notifications when below low throughput threshold
#
# Example:
# sns-message-types: scale-up, scale-down, throughput-alarm
# sns-message-types: scale-up, scale-down, high-throughput-alarm, low-throughput-alarm

#
# Other settings
Expand Down
4 changes: 2 additions & 2 deletions dynamic_dynamodb/aws/sns.py
Expand Up @@ -20,7 +20,7 @@ def publish_gsi_notification(
:type message: str
:param message: Message to send via SNS
:type message_types: list
:param message_types: List with types: scale-up, scale-down, throughput-alarm
:param message_types: List with types: scale-up, scale-down, high-throughput-alarm, low-throughput-alarm
:type subject: str
:param subject: Subject to use for e-mail notifications
:returns: None
Expand All @@ -44,7 +44,7 @@ def publish_table_notification(table_key, message, message_types, subject=None):
:type message: str
:param message: Message to send via SNS
:type message_types: list
:param message_types: List with types: scale-up, scale-down, throughput-alarm
:param message_types: List with types: scale-up, scale-down, high-throughput-alarm, low-throughput-alarm
:type subject: str
:param subject: Subject to use for e-mail notifications
:returns: None
Expand Down
16 changes: 10 additions & 6 deletions dynamic_dynamodb/config/__init__.py
Expand Up @@ -29,8 +29,10 @@
'log_config_file': None
},
'table': {
'reads-alarm-threshold': 0,
'writes-alarm-threshold': 0,
'reads-upper-alarm-threshold': 0,
'reads-lower-alarm-threshold': 0,
'writes-upper-alarm-threshold': 0,
'writes-lower-alarm-threshold': 0,
'enable_reads_autoscaling': True,
'enable_writes_autoscaling': True,
'reads_lower_threshold': 30,
Expand Down Expand Up @@ -63,8 +65,10 @@
'sns_message_types': []
},
'gsi': {
'reads-alarm-threshold': 0,
'writes-alarm-threshold': 0,
'reads-upper-alarm-threshold': 0,
'reads-lower-alarm-threshold': 0,
'writes-upper-alarm-threshold': 0,
'writes-lower-alarm-threshold': 0,
'enable_reads_autoscaling': True,
'enable_writes_autoscaling': True,
'reads_lower_threshold': 30,
Expand Down Expand Up @@ -333,7 +337,7 @@ def __check_gsi_rules(configuration):
gsi['increase_reads_with'] = 100

# Check sns-message-types
valid_sns_message_types = ['scale-up', 'scale-down', 'throughput-alarm']
valid_sns_message_types = ['scale-up', 'scale-down', 'high-throughput-alarm', 'low-throughput-alarm']
if gsi['sns_message_types']:
for sns_type in gsi['sns_message_types']:
if sns_type not in valid_sns_message_types:
Expand Down Expand Up @@ -418,7 +422,7 @@ def __check_table_rules(configuration):
sys.exit(1)

# Check sns-message-types
valid_sns_message_types = ['scale-up', 'scale-down', 'throughput-alarm']
valid_sns_message_types = ['scale-up', 'scale-down', 'high-throughput-alarm', 'low-throughput-alarm']
if table['sns_message_types']:
for sns_type in table['sns_message_types']:
if sns_type not in valid_sns_message_types:
Expand Down
40 changes: 32 additions & 8 deletions dynamic_dynamodb/config/config_file_parser.py
Expand Up @@ -170,14 +170,26 @@ def parse(config_path):
current_section,
[
{
'key': 'reads-alarm-threshold',
'option': 'reads-alarm-threshold',
'key': 'reads-upper-alarm-threshold',
'option': 'reads-upper-alarm-threshold',
'required': False,
'type': 'int'
},
{
'key': 'writes-alarm-threshold',
'option': 'writes-alarm-threshold',
'key': 'reads-lower-alarm-threshold',
'option': 'reads-lower-alarm-threshold',
'required': False,
'type': 'int'
},
{
'key': 'writes-upper-alarm-threshold',
'option': 'writes-upper-alarm-threshold',
'required': False,
'type': 'int'
},
{
'key': 'writes-lower-alarm-threshold',
'option': 'writes-lower-alarm-threshold',
'required': False,
'type': 'int'
},
Expand Down Expand Up @@ -392,14 +404,26 @@ def parse(config_path):
current_section,
[
{
'key': 'reads-alarm-threshold',
'option': 'reads-alarm-threshold',
'key': 'reads-upper-alarm-threshold',
'option': 'reads-upper-alarm-threshold',
'required': False,
'type': 'int'
},
{
'key': 'reads-lower-alarm-threshold',
'option': 'reads-lower-alarm-threshold',
'required': False,
'type': 'int'
},
{
'key': 'writes-upper-alarm-threshold',
'option': 'writes-upper-alarm-threshold',
'required': False,
'type': 'int'
},
{
'key': 'writes-alarm-threshold',
'option': 'writes-alarm-threshold',
'key': 'writes-lower-alarm-threshold',
'option': 'writes-lower-alarm-threshold',
'required': False,
'type': 'int'
},
Expand Down

0 comments on commit a5ebcb8

Please sign in to comment.