Skip to content

Commit ea4871a

Browse files
committed
Document for prewarmed container
1 parent 1274fdf commit ea4871a

File tree

1 file changed

+106
-0
lines changed

1 file changed

+106
-0
lines changed

docs/prewarm.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<!--
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed with
5+
# this work for additional information regarding copyright ownership.
6+
# The ASF licenses this file to You under the Apache License, Version 2.0
7+
# (the "License"); you may not use this file except in compliance with
8+
# the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
-->
19+
20+
# runtimes
21+
22+
the runtime is the docker image for different language, e.g. nodejs:N, python:N, swift:N, etc.
23+
24+
when user invokes actions, these relative activations are run on docker containers which base on
25+
these runtime docker images.
26+
27+
# Prewarmed container without `reactive`
28+
29+
Prewarmed containers are created when invoker starts, they are created according to runtimes.json's stemCells, e.g.
30+
31+
```
32+
{
33+
"kind": "nodejs:10",
34+
"default": true,
35+
"image": {
36+
"prefix": "openwhisk",
37+
"name": "action-nodejs-v10",
38+
"tag": "nightly"
39+
},
40+
"deprecated": false,
41+
"attached": {
42+
"attachmentName": "codefile",
43+
"attachmentType": "text/plain"
44+
},
45+
"stemCells": [
46+
{
47+
"initialCount": 2,
48+
"memory": "256 MB"
49+
}
50+
]
51+
}
52+
```
53+
Regarding above runtime(nodejs:10 kind + 256 MB memory), `2` prewarmed conatainrs will be created when invoker starts,
54+
and the number of prewarmed container is stable usually, when activation is scheduled on the prewarmed container,
55+
another new prewarmed container will be created at the same time, on the other hand, previous used prewarmed container
56+
is moved from `prewarmedPool` to `busyPool`.
57+
58+
the activation will be scheduled on prewarmed container firstly, then subsequent activation will be scheduled on warmed containers.
59+
because prewarm container is already created in advance, so this can avoid `cold start`.
60+
61+
# Prewarmed container with `reactive`
62+
63+
`Adjust the prewarmed container resource dynamically` is supported by `reactive` configuration, e.g.
64+
```
65+
{
66+
"kind": "nodejs:10",
67+
"default": true,
68+
"image": {
69+
"prefix": "openwhisk",
70+
"name": "action-nodejs-v10",
71+
"tag": "nightly"
72+
},
73+
"deprecated": false,
74+
"attached": {
75+
"attachmentName": "codefile",
76+
"attachmentType": "text/plain"
77+
},
78+
"stemCells": [
79+
{
80+
"initialCount": 2,
81+
"memory": "256 MB",
82+
"reactive": {
83+
"minCount": 1,
84+
"maxCount": 4,
85+
"ttl": "2 minutes",
86+
"threshold": 1,
87+
"increment": 1
88+
}
89+
]
90+
}
91+
```
92+
`reactive` fields explanation:
93+
* minCount: exist at least `minCount` prewarmed containers.
94+
* maxCount: can't create more than `maxCount`prewarmed containers.
95+
* ttl: the prewarmed conainers will be deleted due to expiration, because they are not used in ttl time.
96+
* threshold and increment: these two fileds are used together to calculate the new created number of prewarmed containers.
97+
98+
How to support `adjust the prewarmed container resource dynamically`
99+
100+
* Some prewarmed containers will be deleted if they are expiration, this can save some memory resource.
101+
* Create a certain range prewarmed conainers according to the cold start in same kind on next schedule time, e.g.
102+
- cold start number = 2, number of prewarmed container will be created = cold start number(2)/threshold(2) * increment(1) = 1
103+
- cold start number = 4, number of prewarmed container will be created = cold start number(4)/threshold(2) * increment(1) = 2
104+
- cold start number = 8, number of prewarmed container will be created = cold start number(8)/threshold(2) * increment(1) = 4
105+
- cold start number = 16, number of prewarmed container will be created = 4(cannot exceed the maximum value)
106+
- if cold start doesn't happen, `minCount` prewarmed container will be created on next schedule time.

0 commit comments

Comments
 (0)