Event Scheduling
- Create Scheduled Event
- Get Scheduled Event
- Get all Scheduled Events
- Update Scheduled Event
- Delete Scheduled Event
Use the Event Scheduling API to schedule a scale-up of an existing nodegroup, or create a new nodegroup at a precise time. Use a tool like this date-to-millisecond-calculator to generate the date in miliseconds
required. Note that this is universal timestamp, so it doesn’t matter what timezone you use to calculate the event time. The eventName
value is for your records only, and should be descriptive of the event that you are scheduling (for example, big-event-saturday-night
).
GUIDE ON GROUP SETUP TIME PLANNING
It is important to note that autoscaling startup times vary based on platform type and instance type. For example, instances on AWS usually take between 70 to 90 seconds whereas Azure VMs can take up to 140 seconds for startup. Startup time includes VM initialization and Red5 Pro service startup. Use this to estimate the total time needed for all your instances to be ready prior to scheduling. And finally make sure to add a buffer time for your cluster spinup.
Scheduling a new nodegroup to be created for a event will require you to initialize your cluster before the actual event time. The function to define the average cluster prepration time can be defined as:
(TOTAL NODES X AVERAGE STARTUP TIME PER NODE) + SETUP BUFFER TIME
So if you require a minimum of 1 origin & 10 edges and your average startup time is assumed to be 120 seconds per node, then you should schedule the event using the Stream Manager Event Scheduler API for, (11 X 120) + 100 = 1320 seconds (22 minutes)
(where 100 is the additional total buffer time for you setup to account for unexpected delay in operations).
Very similarly when you plan to resize (scale-up) an existing nodegroup, you should know that it will take the autoscaling mechanism a minimum of (ADDITIONAL NODES TO SCALE-UP X AVERAGE STARTUP TIME PER NODE)
seconds for the group to reach desired capacity.
NOTE: Currently this feature is only available for use with “simple” clusters (containing origin and edge nodes only).
Create Scheduled Event
Create New Nodegroup For Event
To create and initialize a new nodegroup for an event, at a scheduled time, you must provide an existing launchConfig
name (must exist), a new scalePolicy
name (must not exist) as shown in the JSON data sample below.
REQUEST
- URI :
http://{host}:{port}/streammanager/api/3.1/admin/scheduler?accessToken=<accessToken>
- Method: POST
- Data: JSON
{
"eventName": "<event-name>",
"date": "<date-in-milliseconds>",
"data": {
"launchConfig": "<existing-launch-config-name>",
"scalePolicy": "<new-scale-policy-name>",
"region": [
{
"name": "<region-code>",
"info": {
"minPublishers": "<min-publishers>",
"maxPublishers": "<max-publishers>",
"minSubscribers": "<min-subscribers>",
"maxSubscribers": "<max-subscribers>"
}
}
]
}
}
RESPONSE
- Failure: HTTP CODE
400
or404
- Data:
{
"errorMessage": "<error-message-string>",
"timestamp": <error-timestamp>
}
- Success: HTTP CODE
201
- Data:
{
"id": <autogen-event-id>,
"eventName": "<event-name>",
"date": "<date-in-milliseconds>",
"data": {
"launchConfig": "<launch-config-name>",
"region": [
{
"name": "<region-code>",
"info": {
"minPublishers": "<min-publishers>",
"maxPublishers": "<max-publishers>",
"minSubscribers": "<min-subscribers>",
"maxSubscribers": "<max-subscribers>"
}
}
],
"scalePolicy": "<scale-policy-name>"
},
"state": "<scheduled-job-state>"
}
Example:
REQUEST
- URI:
http://{host}:{port}/streammanager/api/3.1/admin/scheduler?accessToken=xyz123
- Method: POST
- Data : JSON
{
"eventName": "auction",
"date": "1537525200000",
"data": {
"launchConfig": "default",
"scalePolicy": "auction",
"region": [
{
"name": "us-east-1",
"info": {
"minPublishers": "15",
"maxPublishers": "20",
"minSubscribers": "15",
"maxSubscribers": "20"
}
}
]
}
}
RESPONSE
- Success: HTTP CODE
201
- Data:
{
"id": 1,
"eventName": "auction",
"date": "1537525200000",
"data": {
"launchConfig": "default",
"region": [
{
"name": "us-east-1",
"info": {
"minSubscribers": "15",
"minPublishers": "15",
"maxPublishers": "20",
"maxSubscribers": "20"
}
}
],
"scalePolicy": "auction"
},
"state": "pending"
}
Resize Existing Nodegroup For Event
To resize an existing nodegroup for an event at a scheduled time, you must specify the name of the target in the data
JSON Object as shown in the sampe below. For an existing nodegroup, launchConfig
and scalePolicy
are not to be specified, as they were already defined in the initial setup of the nodegroup.
REQUEST
- URI:
http://{host}:{port}/streammanager/api/3.1/admin/scheduler?accessToken=<accessToken>
- Method: POST
- Data: JSON
{
"eventName": "<event-name>",
"date": "<date-in-milliseconds>",
"data": {
"nodeGroup": "<nodegroup-name>",
"region": [
{
"name": "<region-code>",
"info": {
"minPublishers": "<min-publishers>",
"maxPublishers": "<max-publishers>",
"minSubscribers": "<min-subscribers>",
"maxSubscribers": "<max-subscribers>"
}
}
]
}
}
RESPONSE
- Failure: HTTP CODE
400
or404
- Data:
{
"errorMessage": "<error-message-string>",
"timestamp": <error-timestamp>
}
- Success: HTTP CODE
201
- Data:
{
"id": <autogen-event-id>,
"eventName": "<event-name>",
"date": "<date-in-milliseconds>",
"data": {
"region": [
{
"name": "<region-code>",
"info": {
"minPublishers": "<min-publishers>",
"maxPublishers": "<max-publishers>",
"minSubscribers": "<min-subscribers>",
"maxSubscribers": "<max-subscribers>"
}
},
"nodeGroup": "<nodegroup-name>",
},
"state": "<scheduled-job-state>"
}
Example:
REQUEST
- URI:
http://{host}:{port}/streammanager/api/3.1/admin/scheduler?accessToken=xyz123
- Method: POST
- Data: JSON
{
"eventName": "auction",
"date": "1537536000000",
"data": {
"nodeGroup": "group-3f5163ec-bbed-4e67-adca-b56b2915be47",
"region": [
{
"name": "us-east-1",
"info": {
"minPublishers": "15",
"maxPublishers": "20",
"minSubscribers": "15",
"maxSubscribers": "20"
}
}
]
}
}
RESPONSE
- Success: HTTP CODE
201
- Data:
{
"id": 9,
"eventName": "auction",
"date": "1537536000000",
"data": {
"region": [
{
"name": "us-east-1",
"info": {
"minSubscribers": "15",
"minPublishers": "15",
"maxPublishers": "20",
"maxSubscribers": "20"
}
}
],
"nodeGroup": "group-3f5163ec-bbed-4e67-adca-b56b2915be47"
},
"state": "pending"
}
Get Scheduled Event
REQUEST
- URI:
http://{host}:{port}/streammanager/api/3.1/admin/scheduler/{eventName}?accessToken=<accessToken>
- Method: GET
RESPONSE
- Failure: HTTP CODE
400
or404
- Data:
{
"errorMessage": "<error-message-string>",
"timestamp": <error-timestamp>
}
- Success: HTTP CODE
200
- Data:
{
"id": <autogen-event-id>,
"eventName": "<event-name>",
"date": "<date-in-milliseconds>",
"data": {
"region": [
{
"name": "<region-code>",
"info": {
"minPublishers": "<min-publishers>",
"maxPublishers": "<max-publishers>",
"minSubscribers": "<min-subscribers>",
"maxSubscribers": "<max-subscribers>"
}
}
],
"launchConfig": "<launch-config-name>",
"scalePolicy": "<scale-policy-name>",
},
"state": "<scheduled-job-state>"
}
Example:
REQUEST
- URI:
http://{host}:{port}/streammanager/api/3.1/admin/scheduler/auction?accessToken=xyz123
- Method: GET
RESPONSE
- Success: HTTP CODE
200
- Data:
{
"id": 4,
"eventName": "auction",
"date": "1537795840000",
"data": {
"launchConfig": "default",
"scalePolicy": "auction",
"region": [
{
"name": "us-east-1",
"info": {
"minSubscribers": "15",
"minPublishers": "15",
"maxPublishers": "20",
"maxSubscribers": "20"
}
}
]
},
"state": "pending"
}
The content of
data
is arbitrary and will depend on the type of scheduling (create/resize) requested and input specified. A create response will containlaunchConfig
andscalePolicy
attributes, whereas resize/update response will contain anodeGroup
attribute denoting the target nodegroup to be resized.
Get all Scheduled Events
REQUEST
- URI:
http://{host}:{port}/streammanager/api/3.1/admin/scheduler?accessToken=<accessToken>
- Method: GET
RESPONSE
- Success: HTTP CODE
200
- Data:
[
{
"id": <autogen-event-id>,
"eventName": "<event-name>",
"date": "<date-in-milliseconds>",
"data": {
"region": [
{
"name": "<region-code>",
"info": {
"minPublishers": "<min-publishers>",
"maxPublishers": "<max-publishers>",
"minSubscribers": "<min-subscribers>",
"maxSubscribers": "<max-subscribers>"
}
}
],
"launchConfig": "<launch-config-name>",
"scalePolicy": "<scale-policy-name>",
},
"state": "<scheduled-job-state>"
}
]
Example:
REQUEST
- URI:
http://{host}:{port}/streammanager/api/3.1/admin/scheduler?accessToken=xyz123
- Method: GET
RESPONSE
- Success: HTTP CODE
200
- Data:
[
{
"id": 4,
"eventName": "auction",
"date": "1537795840000",
"data": {
"launchConfig": "default",
"scalePolicy": "auction",
"region": [
{
"name": "us-east-1",
"info": {
"minSubscribers": "15",
"minPublishers": "15",
"maxPublishers": "20",
"maxSubscribers": "20"
}
}
]
},
"state": "pending"
}
]
The content of
data
is arbitrary and will depend on the type of scheduling (create/resize) requested and input specified. A create response will containlaunchConfig
andscalePolicy
attributes, whereas resize/update response will contain anodeGroup
attribute denoting the target nodegroup to be resized.
Update Scheduled Event
Update a scheduled new nodegroup creation request for an event
REQUEST
- URI:
http://{host}:{port}/streammanager/api/3.1/admin/scheduler/{eventName}?accessToken=<accessToken>
- Method: PUT
- Data: JSON
{
"eventName": "<event-name>",
"date": "<date-in-milliseconds>",
"data": {
"launchConfig": "<launch-config-name>",
"scalePolicy": "<scale-policy-name>",
"region": [
{
"name": "<region-code>",
"info": {
"minPublishers": "<min-publishers>",
"maxPublishers": "<max-publishers>",
"minSubscribers": "<min-subscribers>",
"maxSubscribers": "<max-subscribers>"
}
}
]
}
}
RESPONSE
- Failure: HTTP CODE
400
or404
- Data:
{
"errorMessage": "<error-message-string>",
"timestamp": <error-timestamp>
}
- Success: HTTP CODE
200
- Data:
{
"id": <autogen-event-id>,
"eventName": "<event-name>",
"date": "<date-in-milliseconds>",
"data": {
"launchConfig": "<launch-config-name>",
"region": [
{
"name": "<region-code>",
"info": {
"minPublishers": "<min-publishers>",
"maxPublishers": "<max-publishers>",
"minSubscribers": "<min-subscribers>",
"maxSubscribers": "<max-subscribers>"
}
}
],
"scalePolicy": "<scale-policy-name>"
},
"state": "<scheduled-job-state>"
}
Example:
REQUEST
- URI:
http://{host}:{port}/streammanager/api/3.1/admin/scheduler/auction?accessToken=xyz123
- Method: PUT
- Data: JSON
{
"eventName": "auction",
"date": "1537795840000",
"data": {
"launchConfig": "default",
"scalePolicy": "auction",
"region": [
{
"name": "us-east-1",
"info": {
"minPublishers": "15",
"maxPublishers": "20",
"minSubscribers": "15",
"maxSubscribers": "20"
}
}
]
}
}
RESPONSE
- Success: HTTP CODE
200
- Data:
{
"id": 4,
"eventName": "auction",
"date": "1537795840000",
"data": {
"launchConfig": "default",
"scalePolicy": "auction",
"region": [
{
"name": "us-east-1",
"info": {
"minSubscribers": "15",
"minPublishers": "15",
"maxPublishers": "20",
"maxSubscribers": "20"
}
}
]
},
"state": "pending"
}
Update a scheduled nodegroup resize request
REQUEST
- URI:
http://{host}:{port}/streammanager/api/3.1/admin/scheduler/{eventName}?accessToken=<accessToken>
- Method: PUT
- Data: JSON
{
"eventName": "<event-name>",
"date": "<date-in-milliseconds>",
"nodeGroup": "<nodegroup-name>",
"region": [
{
"name": "<region-code>",
"info": {
"minPublishers": "<min-publishers>",
"maxPublishers": "<max-publishers>",
"minSubscribers": "<min-subscribers>",
"maxSubscribers": "<max-subscribers>"
}
}
]
}
}
RESPONSE
- Failure: HTTP CODE
400
or404
- Data:
{
"errorMessage": "<error-message-string>",
"timestamp": <error-timestamp>
}
- Success: HTTP CODE
200
- Data:
{
"id": <autogen-event-id>,
"eventName": "<event-name>",
"date": "<date-in-milliseconds>",
"data": {
"region": [
{
"name": "<region-code>",
"info": {
"minPublishers": "<min-publishers>",
"maxPublishers": "<max-publishers>",
"minSubscribers": "<min-subscribers>",
"maxSubscribers": "<max-subscribers>"
}
},
"nodeGroup": "<nodegroup-name>",
},
"state": "<scheduled-job-state>"
}
Example:
REQUEST
- URI:
http://{host}:{port}/streammanager/api/3.1/admin/scheduler/auction?accessToken=xyz123
- Method: PUT
- Data: JSON
{
"eventName": "auction",
"date": "1537795840000",
"data": {
"region": [
{
"name": "us-east-1",
"info": {
"minSubscribers": "15",
"minPublishers": "15",
"maxPublishers": "20",
"maxSubscribers": "20"
}
}
],
"nodeGroup": "group-3f5163ec-bbed-4e67-adca-b56b2915be47"
}
}
RESPONSE
- Success: HTTP CODE
200
- Data:
{
"id": 9,
"eventName": "auction",
"date": "1537536000000",
"data": {
"region": [
{
"name": "us-east-1",
"info": {
"minSubscribers": "15",
"minPublishers": "15",
"maxPublishers": "20",
"maxSubscribers": "20"
}
}
],
"nodeGroup": "group-3f5163ec-bbed-4e67-adca-b56b2915be47"
},
"state": "pending"
}
Delete Scheduled Event
REQUEST
- URI:
http://{host}:{port}/streammanager/api/3.1/admin/scheduler/{eventName}?accessToken=<accessToken>
- Method: DELETE
- Data: n/a
RESPONSE
- Failure: HTTP CODE
204
- Success: HTTP CODE
200