Commit 2de1c49
[core] Autoscaler with resource availability (#58623)
## Description
When the Autoscaler receives a resource request and decides which type
of node to scale up,, only the `UtilizationScore` is considered (that
is, Ray tries to avoid launching a large node for a small resource
request, which would lead to resource waste). If multiple node types in
the cluster have the same `UtilizationScore`, Ray always request for the
same node type.
In Spot scenarios, cloud resources are dynamically changing. Therefore,
we want the Autoscaler to be aware of cloud resource availability — if a
certain node type becomes unavailable, the Autoscaler should be able to
automatically switch to requesting other node types.
In this PR, I added the `CloudResourceMonitor` class, which records node
types that have failed resource allocation, and in future scaling
events, reduces the weight of these node types.
## Related issues
Related to #49983
Fixes #53636 #39788 #39789
## implementation details
1. `CloudResourceMonitor`
This is a subscriber of Instances. When a Instance get status of
`ALLOCATION_FAILED`, `CloudResourceMonitor` record the node_type and set
a lower its availability score.
2. `ResourceDemandScheduler`
This class determines how to select the best node_type to handle
resource request. I modify the part of selecting the best node type:
```python
# Sort the results by score.
results = sorted(
results,
key=lambda r: (
r.score,
cloud_resource_availabilities.get(r.node.node_type, 1),
),
reverse=True
)
```
The sorting includes:
2.1. UtilizationScore: to maximize resource utilization.
2.2. Cloud resource availabilities: prioritize node types with the most
available cloud resources, in order to minimize allocation failures.
---------
Signed-off-by: xiaowen.wxw <[email protected]>
Co-authored-by: 行筠 <[email protected]>1 parent 5458c75 commit 2de1c49
File tree
9 files changed
+337
-44
lines changed- python/ray/autoscaler/v2
- instance_manager
- subscribers
- tests
- src/ray/protobuf
9 files changed
+337
-44
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
35 | 38 | | |
36 | 39 | | |
37 | 40 | | |
| |||
76 | 79 | | |
77 | 80 | | |
78 | 81 | | |
| 82 | + | |
79 | 83 | | |
80 | 84 | | |
81 | 85 | | |
| |||
160 | 164 | | |
161 | 165 | | |
162 | 166 | | |
| 167 | + | |
| 168 | + | |
163 | 169 | | |
164 | 170 | | |
165 | 171 | | |
| |||
201 | 207 | | |
202 | 208 | | |
203 | 209 | | |
| 210 | + | |
204 | 211 | | |
205 | 212 | | |
206 | 213 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| |||
225 | 226 | | |
226 | 227 | | |
227 | 228 | | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
228 | 233 | | |
229 | 234 | | |
230 | 235 | | |
| |||
284 | 289 | | |
285 | 290 | | |
286 | 291 | | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
287 | 299 | | |
288 | 300 | | |
289 | 301 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
24 | 27 | | |
25 | 28 | | |
26 | 29 | | |
| |||
62 | 65 | | |
63 | 66 | | |
64 | 67 | | |
| 68 | + | |
65 | 69 | | |
66 | 70 | | |
67 | 71 | | |
| |||
88 | 92 | | |
89 | 93 | | |
90 | 94 | | |
| 95 | + | |
| 96 | + | |
91 | 97 | | |
92 | 98 | | |
93 | 99 | | |
| |||
122 | 128 | | |
123 | 129 | | |
124 | 130 | | |
| 131 | + | |
125 | 132 | | |
126 | 133 | | |
127 | 134 | | |
| |||
161 | 168 | | |
162 | 169 | | |
163 | 170 | | |
164 | | - | |
| 171 | + | |
165 | 172 | | |
166 | 173 | | |
167 | 174 | | |
168 | 175 | | |
169 | 176 | | |
170 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
171 | 182 | | |
172 | 183 | | |
173 | | - | |
| 184 | + | |
174 | 185 | | |
175 | 186 | | |
176 | | - | |
| 187 | + | |
177 | 188 | | |
178 | | - | |
| 189 | + | |
179 | 190 | | |
180 | 191 | | |
181 | | - | |
| 192 | + | |
182 | 193 | | |
183 | | - | |
| 194 | + | |
184 | 195 | | |
185 | 196 | | |
186 | 197 | | |
| |||
227 | 238 | | |
228 | 239 | | |
229 | 240 | | |
| 241 | + | |
230 | 242 | | |
231 | 243 | | |
232 | 244 | | |
| |||
258 | 270 | | |
259 | 271 | | |
260 | 272 | | |
| 273 | + | |
| 274 | + | |
261 | 275 | | |
262 | 276 | | |
263 | 277 | | |
| |||
275 | 289 | | |
276 | 290 | | |
277 | 291 | | |
| 292 | + | |
278 | 293 | | |
279 | 294 | | |
280 | 295 | | |
| |||
711 | 726 | | |
712 | 727 | | |
713 | 728 | | |
| 729 | + | |
714 | 730 | | |
715 | 731 | | |
716 | 732 | | |
| |||
932 | 948 | | |
933 | 949 | | |
934 | 950 | | |
935 | | - | |
| 951 | + | |
936 | 952 | | |
| 953 | + | |
937 | 954 | | |
938 | 955 | | |
939 | 956 | | |
| |||
1060 | 1077 | | |
1061 | 1078 | | |
1062 | 1079 | | |
| 1080 | + | |
1063 | 1081 | | |
1064 | 1082 | | |
1065 | 1083 | | |
| |||
1075 | 1093 | | |
1076 | 1094 | | |
1077 | 1095 | | |
| 1096 | + | |
| 1097 | + | |
1078 | 1098 | | |
1079 | 1099 | | |
1080 | 1100 | | |
| |||
1119 | 1139 | | |
1120 | 1140 | | |
1121 | 1141 | | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
1122 | 1145 | | |
1123 | 1146 | | |
1124 | 1147 | | |
| |||
1195 | 1218 | | |
1196 | 1219 | | |
1197 | 1220 | | |
| 1221 | + | |
1198 | 1222 | | |
1199 | 1223 | | |
1200 | 1224 | | |
| |||
1209 | 1233 | | |
1210 | 1234 | | |
1211 | 1235 | | |
| 1236 | + | |
1212 | 1237 | | |
1213 | 1238 | | |
1214 | 1239 | | |
| |||
1391 | 1416 | | |
1392 | 1417 | | |
1393 | 1418 | | |
1394 | | - | |
1395 | 1419 | | |
1396 | 1420 | | |
1397 | 1421 | | |
| |||
Lines changed: 73 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
0 commit comments