enable_keep_warm
Enable Keep Warm settings for a deployment. If the deployment already has Keep Warm enabled, calling enable_keep_warm
replaces the deployment's Keep Warm settings.
Parameters
mb.enable_keep_warm(...)
deployment
:str
The name of the deployment to use with Keep Warmversion
:int
The version of the deploymentbranch
:Optional[str]
The branch of the deployment. If unspecified, the current branch is used.count
:Optional[int]
The number of warm instances to create for the deployment. Ifcount
andschedule
are omitted, thencount=1
is used as the default.schedule
:Optional[Schedule]
The schedule configuration to use with Keep Warm. See the Examples section for the data format ofSchedule
. Thecount
parameter is ignored if aSchedule
is provided.
Returns
A message is printed saying that Keep Warm was enabled for the deployment.
Examples
Enable one warm instance
mb.enable_keep_warm(deployment="my_deployment", version=12)
If the deployment is on a different branch, use branch=
:
mb.enable_keep_warm(deployment="my_deployment", version=12, branch="project_branch")
Enable multiple warm instances
Use count=
to specify the number of Keep Warm instances:
mb.enable_keep_warm(deployment="my_deployment", version=12, count=3)
Specify a Schedule
To configure different numbers of Keep Warm instances throughout the day, or throughout the week, use a Schedule
.
The Schedule specifies a timezone and the warm instances for each day. Each warm instance has a start and stop hour. The root type of Schedule
is a Dict
, with the following properties:
timezone
:str
The timezone used to interpret the schedule's hours. The timezone must be one of:UTC
,Australia/Sydney
,Australia/Adelaide
,America/Anchorage
,America/Puerto_Rico
,America/Chicago
,America/New_York
,America/Denver
,America/Los_Angeles
,America/Rio_Branco
,America/Sao_Paulo
,Africa/Maputo
,Africa/Lagos
,Africa/Nairobi
,Europe/Berlin
,Europe/Kiev
,Europe/Athens
,Europe/Madrid
,Europe/London
,Europe/Istanbul
,Europe/Paris
,Europe/Rome
,Europe/Warsaw
,Europe/Dublin
,Europe/Lisbon
,Asia/Tokyo
,Asia/Hong_Kong
,Asia/Seoul
,Asia/Bangkok
,Asia/Shanghai
,Asia/Riyadh
,Asia/Karachi
,Asia/Kolkata
,Asia/Jerusalem
.days
:List[List[InstanceSchedule] | None]
The schedule specifying when to start/stop warm instances for that day. The list must be 7 long (one for each day of the week), and the 0th day is Sunday.InstanceSchedule
is aDict
of the form{ "start_hour": int, "end_hour": int }
. Each day can have up to 6InstanceSchedule
entries, and the entries do not need to match or overlap.- Use
None
for any day that does not have any Keep Warm instances.
Enable one warm instance all day on Tuesday:
mb.enable_keep_warm(
deployment="my_deployment",
version=26,
schedule={
"timezone": "America/Chicago",
"days": [
None, # Sunday
None, # Monday
[{"start_hour": 0, "end_hour": 24 }], # Tuesday
None, # Wednesday
None, # Thursday
None, # Friyay
None, # Saturday
]
},
)
Enable two warm instances during business hours
Use overlapping schedules to keep 1 instance warm all the time, and a second instance warm during business hours:
twoWarmInstances = [
{"start_hour": 0, "end_hour": 24 }, # All day
{"start_hour": 6, "end_hour": 18 }, # Extra capacity during business hours
]
mb.enable_keep_warm(
deployment="my_deployment",
version=26,
schedule={
"timezone": "UTC",
"days": [
None, # Sunday
twoWarmInstances,
twoWarmInstances,
twoWarmInstances,
twoWarmInstances,
twoWarmInstances,
None,
]
},
)