/

Scale Policy Management


NOTES ON SCALE POLICIES:

  • The scale policy v3 ensures that if you have nodes across multiple regions, the stream manager will scale up and down to maintain viable nodes in each designated region.
  • The policy supports two optional attributes per role target - scaleInWaitTime & scaleOutWaitTime. These parameters denote delayed scale-in/scale-out time in milliseconds. The attributes require positive values (>=0). If the attribute is omitted, the value defaults to 0.
  • You can create a policy for different node values in different regions (for example, if your publisher is in one region but your subscribers are in multiple regions). See example below.

Create Scale Policy

Description

Create a new scale policy. Note: if you intend to use the Autoscaling Tier 2 functionality, you need a minimum of two each origin, edge and relay nodes per group. If you are also using the Adaptive Bitrate Susbcriber or VP8 Transcode functionality, then you would need at least two transcode nodes per group.

REQUEST

  • URI: http://{host}:{port}/streammanager/api/4.0/admin/configurations/scalepolicy?accessToken=<accessToken>
  • Method: POST
  • Data: JSON
   {
  "policy": {
          "name": "<policy-name>",
          "description": "<policy-description>",
          "type": "<policy-type>",
          "version": "<policy-version>",
          "targets": {
              "region": [
                  {
                      "name": "default",
                      "target": [
        {
          "role": "<role>",
          "minLimit": "<min-node-count>",
          "maxLimit": "<max-node-count>",
          "scaleAdjustment": "<node-scale-adjustment>"
        }
      ]
    }
    }}

RESPONSE

  • Failure: HTTP CODE 400 or 404
  • Data:
    {
      "errorMessage": "<error-message-string>",
      "timestamp": <error-timestamp>
    }
  • Success: HTTP CODE 201
  • Data:
     {
   "policy": {
     "name": "<policy-name>",
     "description": "<policy-description>>",
     "version": "<policy-version>",
     "type": "<policy-type>",
     "targets": {
       "target": [{
         "role": "<role>",
         "minLimit": "<min-node-count>",
         "maxLimit": "<max-node-count>",
         "scaleAdjustment": "<node-scale-adjustment>"
       }]
     }
   }}

Example 01

REQUEST

  • URI: http://{host}:{port}/streammanager/api/4.0/admin/configurations/scalepolicy?accessToken=xyz123
  • Method: POST
  • Data: JSON
   {
      "policy": {
          "name": "alltypes-01",
          "description": "Scale policy file with all node types",
          "type": "com.red5pro.services.autoscaling.model.ScalePolicyMaster",
          "version": "0.0.3",
          "targets": {
              "region": [
                  {
                      "name": "default",
                      "target": [
                          {
                              "role": "edge",
                              "minLimit": 2,
                              "maxLimit": 20,
                              "scaleAdjustment": 1
                          },
                          {
                              "role": "origin",
                              "minLimit": 2,
                              "maxLimit": 20,
                              "scaleAdjustment": 1
                          },
                                                    {
                              "role": "relay",
                              "minLimit": 2,
                              "maxLimit": 20,
                              "scaleAdjustment": 1
                          },
                                                    {
                              "role": "transcoder",
                              "minLimit": 2,
                              "maxLimit": 20,
                              "scaleAdjustment": 1
                          }
                      ]
                  }
                      ]
                  }
      }
  }

RESPONSE

  • Success: HTTP CODE 201
  • Data:
{
    "policy": {
        "name": "alltypes-01",
        "description": "Scale policy file with all node types",
        "type": "com.red5pro.services.autoscaling.model.ScalePolicyMaster",
        "version": "0.0.3",
        "targets": {
            "region": [
                {
                    "name": "default",
                    "target": [
                        {
                            "role": "edge",
                            "maxLimit": 20,
                            "scaleAdjustment": 1,
                            "minLimit": 2
                        },
                        {
                            "role": "origin",
                            "maxLimit": 20,
                            "scaleAdjustment": 1,
                            "minLimit": 2
                        },
                        {
                            "role": "relay",
                            "maxLimit": 20,
                            "scaleAdjustment": 1,
                            "minLimit": 2
                        },
                        {
                            "role": "transcoder",
                            "maxLimit": 20,
                            "scaleAdjustment": 1,
                            "minLimit": 2
                        }
                    ]
                }
            ]
        }
    }
}

Example 02 - multiple regions

The following is an example for a nodegroup with one origin and one edge in us-east-2, and two edges (no origins) in us-west-2. Note that the default region must also be included in this policy, and even if no origin nodes are included in the second region, the node type must still be defined.

To use this scale policy in nodegroup creation, both regions must be targeted in the nodegroup creation as well.

REQUEST

  • URI: http://{host}:{port}/streammanager/api/4.0/admin/configurations/scalepolicy?accessToken=xyz123
  • Method: POST
  • Data: JSON
{
      "policy": {
          "name": "oe-multiregion",
          "description": "This is a sample 3rd generation scale policy file with two of each node type",
          "type": "com.red5pro.services.autoscaling.model.ScalePolicyMaster",
          "version": "0.0.3",
          "targets": {
              "region": [
                  {
                      "name": "default",
                      "target": [
                          {
                              "role": "edge",
                              "estimatedWarmUpTime": 150000,
                              "maxLimit": 20,
                              "scaleAdjustment": 1,
                              "coolDownPeriod": 180000,
                              "minLimit": 1
                          },
                          {
                              "role": "origin",
                              "estimatedWarmUpTime": 150000,
                              "maxLimit": 10,
                              "scaleAdjustment": 1,
                              "coolDownPeriod": 180000,
                              "minLimit": 1
                          }
                      ]
                  },
                  {
                      "name": "us-east-2",
                      "target": [
                          {
                              "role": "edge",
                              "estimatedWarmUpTime": 150000,
                              "maxLimit": 20,
                              "scaleAdjustment": 1,
                              "coolDownPeriod": 180000,
                              "minLimit": 2
                          },
                          {
                              "role": "origin",
                              "estimatedWarmUpTime": 150000,
                              "maxLimit": 10,
                              "scaleAdjustment": 1,
                              "coolDownPeriod": 180000,
                              "minLimit": 1
                          }
                      ]
                  },
                  {
                      "name": "us-west-2",
                      "target": [
                          {
                              "role": "edge",
                              "estimatedWarmUpTime": 150000,
                              "maxLimit": 20,
                              "scaleAdjustment": 1,
                              "coolDownPeriod": 180000,
                              "minLimit": 2
                          },
                          {
                              "role": "origin",
                              "estimatedWarmUpTime": 150000,
                              "maxLimit": 10,
                              "scaleAdjustment": 1,
                              "coolDownPeriod": 180000,
                              "minLimit": 0
                          }
                      ]
                  }
                      ]
                  }
      }
  }

Read Scale Policy

Description

Read a scale policy.

REQUEST

  • URI: http://{host}:{port}/streammanager/api/4.0/admin/configurations/scalepolicy/{policy-name}?accessToken=<accessToken>
  • Method: GET
  • Data: NA

RESPONSE

  • Failure: HTTP CODE 400 or 404
  • Data:
    {
      "errorMessage": "<error-message-string>",
      "timestamp": <error-timestamp>
    }
  • Success: HTTP CODE 200
  • Data:
     {
   "policy": {
     "name": "<policy-name>",
     "description": "<policy-description>>",
     "version": "<policy-version>",
     "type": "<policy-type>",
     "targets": {
       "target": [{
         "role": "<role>",
         "minLimit": "<min-node-count>",
         "maxLimit": "<max-node-count>",
         "scaleAdjustment": "<node-scale-adjustment>"
       }]
     }
   }}

Example

REQUEST

  • URI: http://{host}:{port}/streammanager/api/4.0/admin/configurations/scalepolicy/alltypes-01?accessToken=xyz123
  • Method: GET
  • Data: NA

RESPONSE

  • Success: HTTP CODE 200
  • Data:
{
    "policy": {
        "name": "alltypes-01",
        "description": "Scale policy file with all node types",
        "type": "com.red5pro.services.autoscaling.model.ScalePolicyMaster",
        "version": "0.0.3",
        "targets": {
            "region": [
                {
                    "name": "default",
                    "target": [
                        {
                            "role": "edge",
                            "maxLimit": 20,
                            "scaleAdjustment": 1,
                            "minLimit": 2
                        },
                        {
                            "role": "origin",
                            "maxLimit": 20,
                            "scaleAdjustment": 1,
                            "minLimit": 2
                        },
                        {
                            "role": "relay",
                            "maxLimit": 20,
                            "scaleAdjustment": 1,
                            "minLimit": 2
                        },
                        {
                            "role": "transcoder",
                            "maxLimit": 20,
                            "scaleAdjustment": 1,
                            "minLimit": 2
                        }
                    ]
                }
            ]
        }
    }
}

Delete Scale Policy

Description

Delete a scale policy.

REQUEST

  • URI: http://{host}:{port}/streammanager/api/4.0/admin/configurations/scalepolicy/{policy-name}?accessToken=<accessToken>
  • Method: DELETE
  • Data: NA

RESPONSE

  • Failure: HTTP CODE 400 or 404
  • Data:
    {
      "errorMessage": "<error-message-string>",
      "timestamp": <error-timestamp>
    }
  • Success: HTTP CODE 200
  • Data:
     {
   "policy": {
     "name": "<policy-name>",
     "description": "<policy-description>>",
     "version": "<policy-version>",
     "type": "<policy-type>",
     "targets": {
       "target": [{
         "role": "<role>",
         "minLimit": "<min-node-count>",
         "maxLimit": "<max-node-count>",
         "scaleAdjustment": "<node-scale-adjustment>"
       }]
     }
   }}

Example

REQUEST

  • URI: http://{host}:{port}/streammanager/api/4.0/admin/configurations/scalepolicy/alltypes-01?accessToken=xyz123
  • Method: DELETE
  • Data: NA

RESPONSE

  • Success: HTTP CODE 200
  • Data:
{
    "policy": {
        "name": "alltypes-01",
        "description": "Scale policy file with all node types",
        "type": "com.red5pro.services.autoscaling.model.ScalePolicyMaster",
        "version": "0.0.3",
        "targets": {
            "region": [
                {
                    "name": "default",
                    "target": [
                        {
                            "role": "edge",
                            "maxLimit": 20,
                            "scaleAdjustment": 1,
                            "minLimit": 2
                        },
                        {
                            "role": "origin",
                            "maxLimit": 20,
                            "scaleAdjustment": 1,
                            "minLimit": 2
                        },
                        {
                            "role": "relay",
                            "maxLimit": 20,
                            "scaleAdjustment": 1,
                            "minLimit": 2
                        },
                        {
                            "role": "transcoder",
                            "maxLimit": 20,
                            "scaleAdjustment": 1,
                            "minLimit": 2
                        }
                    ]
                }
            ]
        }
    }
}

Update Scale Policy

Description

Updates a scale policy

REQUEST

  • URI: http://{host}:{port}/streammanager/api/4.0/admin/configurations/scalepolicy/{policy-name}?accessToken=<accessToken>
  • Method: PUT
  • Data: JSON
   {
    "policy": {
        "name": "<policy-name>",
        "description": "<policy-description>>",
        "version": "<policy-version>",
        "type": "<policy-type>",
    "targets": {
      "target": [
        {
          "role": "<role>",
          "minLimit": "<min-node-count>",
          "maxLimit": "<max-node-count>",
          "scaleAdjustment": "<node-scale-adjustment>"
        }
      ]
    }
    }}

RESPONSE

  • Failure: HTTP CODE 400 or 404
  • Data:
    {
      "errorMessage": "<error-message-string>",
      "timestamp": <error-timestamp>
    }
  • Success: HTTP CODE 200
  • Data:
     {
     "policy": {
       "name": "<policy-name>",
       "description": "<policy-description>>",
       "version": "<policy-version>",
       "type": "<policy-type>",
       "targets": {
         "target": [{
           "role": "<role>",
           "minLimit": "<min-node-count>",
           "maxLimit": "<max-node-count>",
           "scaleAdjustment": "<node-scale-adjustment>"
         }]
       }
     }}

NOTES ON UPDATE API:

  • Only minLimit and maxLimit properties should be updated while the policy is in use by one or more node groups.
  • Any part of the policy can be updated while the policy is not in use by any of the node groups.

Example

REQUEST

  • URI: http://{host}:{port}/streammanager/api/4.0/admin/configurations/scalepolicy/alltypes-01?accessToken=xyz123
  • Method: PUT
  • Data: JSON
  {
      "policy": {
          "name": "alltypes-01",
          "description": "Scale policy file with all node types",
          "type": "com.red5pro.services.autoscaling.model.ScalePolicyMaster",
          "version": "0.0.3",
          "targets": {
              "region": [
                  {
                      "name": "default",
                      "target": [
                          {
                              "role": "edge",
                              "minLimit": 2,
                              "maxLimit": 30,
                              "scaleAdjustment": 1
                          },
                          {
                              "role": "origin",
                              "minLimit": 2,
                              "maxLimit": 30,
                              "scaleAdjustment": 1
                          },
                                                    {
                              "role": "relay",
                              "minLimit": 2,
                              "maxLimit": 30,
                              "scaleAdjustment": 1
                          },
                                                    {
                              "role": "transcoder",
                              "minLimit": 2,
                              "maxLimit": 30,
                              "scaleAdjustment": 1
                          }
                      ]
                  }
                      ]
                  }
      }
  }

RESPONSE

  • Success: HTTP CODE 200
  • Data:
  {
      "policy": {
          "name": "alltypes-01",
          "description": "Scale policy file with all node types",
          "type": "com.red5pro.services.autoscaling.model.ScalePolicyMaster",
          "version": "0.0.3",
          "targets": {
              "region": [
                  {
                      "name": "default",
                      "target": [
                          {
                              "role": "edge",
                              "minLimit": 2,
                              "maxLimit": 30,
                              "scaleAdjustment": 1
                          },
                          {
                              "role": "origin",
                              "minLimit": 2,
                              "maxLimit": 30,
                              "scaleAdjustment": 1
                          },
                                                    {
                              "role": "relay",
                              "minLimit": 2,
                              "maxLimit": 30,
                              "scaleAdjustment": 1
                          },
                                                    {
                              "role": "transcoder",
                              "minLimit": 2,
                              "maxLimit": 30,
                              "scaleAdjustment": 1
                          }
                      ]
                  }
                      ]
                  }
      }
  }

List Scale Policies

Description

List scale policies by name

REQUEST

  • URI : http://{host}:{port}/streammanager/api/4.0/admin/configurations/scalepolicy?accessToken=<accessToken>
  • Method: GET
  • Data: NA

RESPONSE

  • Failure: HTTP CODE 400 or 404
  • Data:
    {
      "errorMessage": "<error-message-string>",
      "timestamp": <error-timestamp>
    }
  • Success: HTTP CODE 200
  • Data:
     [
      "<policy-name>"
    ]

Example

REQUEST

  • URI: http://{host}:{port}/streammanager/api/4.0/admin/configurations/scalepolicy?accessToken=xyz123
  • Method: GET
  • Data: NA

RESPONSE

  • Success: HTTP CODE 200
  • Data:
    [
      "config-01",
      "alltypes-01"
      "default-v3"
    ]

Clone Scale Policy

Description

Creates a new scale policy with a new name using the data from an existing policy.

REQUEST

  • URI : http://{host}:{port}/streammanager/api/4.0/admin/configurations/scalepolicy/<existing-policy-name>/copy/<new-policy-name>?accessToken=<accessToken>
  • Method: POST
  • Data: NA

RESPONSE

  • Failure: HTTP CODE 400 or 404
  • Data:
    {
      "errorMessage": "<error-message-string>",
      "timestamp": <error-timestamp>
    }
  • Success: HTTP CODE 201
  • Data:
     {
     "policy": {
       "name": "<policy-name>",
       "description": "<policy-description>>",
       "version": "<policy-version>",
       "type": "<policy-type>",
       "targets": {
         "target": [{
           "role": "<role>",
           "minLimit": "<min-node-count>",
           "maxLimit": "<max-node-count>",
           "scaleAdjustment": "<node-scale-adjustment>"
         }]
       }
     }}

Example

REQUEST

  • URI: http://{host}:{port}/streammanager/api/4.0/admin/configurations/scalepolicy/alltypes-01/copy/alltypes-02?accessToken=xyz123
  • Method: POST
  • Data: n/a

RESPONSE

  • Success: HTTP CODE 201
  • Data:
{
    "policy": {
        "name": "alltypes-02",
        "description": "Scale policy file with all node types",
        "type": "com.red5pro.services.autoscaling.model.ScalePolicyMaster",
        "version": "0.0.3",
        "targets": {
            "region": [
                {
                    "name": "default",
                    "target": [
                        {
                            "role": "edge",
                            "maxLimit": 20,
                            "scaleAdjustment": 1,
                            "minLimit": 2
                        },
                        {
                            "role": "origin",
                            "maxLimit": 20,
                            "scaleAdjustment": 1,
                            "minLimit": 2
                        },
                        {
                            "role": "relay",
                            "maxLimit": 20,
                            "scaleAdjustment": 1,
                            "minLimit": 2
                        },
                        {
                            "role": "transcoder",
                            "maxLimit": 20,
                            "scaleAdjustment": 1,
                            "minLimit": 2
                        }
                    ]
                }
            ]
        }
    }
}