In the following documentation, you can learn how to use the versioning capability within Spotinst Functions. You can also find information on how to distribute incoming traffic across multiple versions using pre-defined weights.
By default, every time you update one of the following parameters in your function, a new version is being created:
- Code
- Handler
- Memory
The versions will have a unique incremental id (starting from 0) for identification. Each function version is immutable and cannot be changed.
Latest Version
The ‘Latest’ version refers to the last version created for the function when you last updated it. By default, all of the incoming traffic is routed to the ‘latest’ version (unless specified otherwise). The purpose of the ‘Latest’ tag is to help you route your traffic to the last updated version, without specifying the version id.
Please note that the ‘Latest’ tag will point to a different version each time you update your function.
When first creating a Spotinst Function, the default configuration for activeVersions is as following:
{
"activeVersions": [
{
"version": "$LATEST",
"percentage": 100
}
]
}
Active Version
‘Active’ version represents the current active version(s) of your function that will be executed when invoking your function. By default, the ‘Active’ version is pointing to the ‘Latest’, meaning that every update to your function will also affect your ‘Active’ version. However, you can also overwrite the default configuration and change the version(s) associated with the ‘Active’ version.
The ‘Active’ version can point to more than one version of your function (including ‘Latest’). This allows you to distribute your incoming traffic between multiple versions and dictate what percentage is sent to each version.
For example, you can specify that 90% of incoming traffic is routed to a specific version which is the current version that serves production traffic. While 10% of the traffic will be routed to a new version you want to test and analyze before determining if it is production-ready. As you get confident with the new version, you can update your Active version configuration and gradually route more traffic to the new version.
Use cases and examples:
- `Active` = `Latest` = 100%
{ "activeVersions": [ { "version": "$LATEST", "percentage": 100 } ] }
In this example, the 'active' version is your latest version of your function. Every time you update your function, all of the traffic will point to the newest version - Distribute traffic between the 'latest' version and a specific version(s)
{ "activeVersions": [ { "version": "$LATEST", "percentage": 10 }, { "version": "2", "percentage": 90 } ] }
In this example, the traffic is distributing between the 'latest' version and a specific version ID (can be more than 2 versions). This method can be useful for Canary Deployments (when you deploy a new version and don’t want to send all of the traffic to the ‘Latest’ version without testing it first) - Distribute traffic between two (or more) versions
{ "activeVersions": [ { "version": "4", "percentage": 10 }, { "version": "2", "percentage": 40 }, { "version": "3", "percentage": 50 } ] }
In this case, the traffic will be distributed between two versions (v2 and v3). Using this method, every change you are making to your function (i.e. ‘Latest’) won’t affect your production traffic.
Configure Active Version
You can configure your ‘Active’ version by using any of the following methods:
- Configure Active version at the time you update a function
You can use the `update` API request to change your ‘Active’ version configuration by adding the `activeVersions`. For example:
{
"function": {
"limits": {
"memory": 256
},
"activeVersions": [
{
"version": "$LATEST",
"percentage": 80.6
},
{
"version": "2",
"percentage": 4
},
{
"version": "3",
"percentage": 15.4
}
]
}
}
Please note, when updating your function, the ‘Latest’ object is referring to the new version that was created following the update request
- Explicitly configure the ‘Active’ Version
In case you want to change your ‘Active’ version configuration without updating your function (for example, to change the ratio between your versions), you can use the “Configure Active Version” action from the console or using the`update` API request (send only the activeVersion object).
Using the Console:
- Navigate to your function
- Click Actions
- Select Configure Active Version
Note
-
The sum of all percentages must be 100
-
You can set up to two decimal digits in the percentage value
-
You cannot set two weight values directed towards the same version. For example, if the ‘Latest’ version is version 3, you cannot set weight values for both the ‘Latest’ version and version 3.
Example:
‘Latest’ = Version 3 and Active Version configuration is as following:{ "activeVersions": [ { "version": "$LATEST", "percentage": 70 }, { "version": "2", "percentage": 30 } ] }
This will point 70% of the traffic to the Latest version which is currently version 3. Once you update your function, 70% of the traffic will still be routed to ‘Latest’ which will now point to Version 4.In case you want to point the traffic permanently to version 1, also in the event of Function update, you should set:
{ "activeVersions": [ { "version": "3", "percentage": 70 }, { "version": "2", "percentage": 30 } ] }
Comments
0 comments
Please sign in to leave a comment.