@radicaltools/cli 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +121 -16
- package/dist/hub-catalogue/concern/concern-api-collections.radical +1136 -0
- package/dist/hub-catalogue/concern/concern-api-errors.radical +1180 -0
- package/dist/hub-catalogue/concern/concern-api-evolution.radical +449 -210
- package/dist/hub-catalogue/concern/concern-api-idempotency.radical +1218 -0
- package/dist/hub-catalogue/concern/concern-api-resource-design.radical +1102 -0
- package/dist/hub-catalogue/concern/concern-api-style-guide.radical +1210 -0
- package/dist/hub-catalogue/concern/concern-architecture-style.radical +287 -131
- package/dist/hub-catalogue/concern/concern-audit-trail.radical +1096 -0
- package/dist/hub-catalogue/concern/concern-authentication.radical +247 -37
- package/dist/hub-catalogue/concern/concern-authorization.radical +311 -89
- package/dist/hub-catalogue/concern/concern-availability.radical +287 -63
- package/dist/hub-catalogue/concern/concern-backend-stack.radical +300 -381
- package/dist/hub-catalogue/concern/concern-backup-recovery.radical +385 -129
- package/dist/hub-catalogue/concern/concern-caching.radical +1294 -0
- package/dist/hub-catalogue/concern/concern-capacity.radical +194 -81
- package/dist/hub-catalogue/concern/concern-code-documentation.radical +1397 -0
- package/dist/hub-catalogue/concern/concern-code-quality-gate.radical +1409 -0
- package/dist/hub-catalogue/concern/concern-code-review-branching.radical +1416 -0
- package/dist/hub-catalogue/concern/concern-code-style.radical +1058 -0
- package/dist/hub-catalogue/concern/concern-communication-style.radical +473 -167
- package/dist/hub-catalogue/concern/concern-data-classification.radical +970 -0
- package/dist/hub-catalogue/concern/concern-data-consistency.radical +339 -308
- package/dist/hub-catalogue/concern/concern-data-store.radical +480 -158
- package/dist/hub-catalogue/concern/concern-decomposition.radical +260 -85
- package/dist/hub-catalogue/concern/concern-definition-of-done.radical +1214 -0
- package/dist/hub-catalogue/concern/concern-delivery-metrics.radical +966 -0
- package/dist/hub-catalogue/concern/concern-dependency-hygiene.radical +1345 -0
- package/dist/hub-catalogue/concern/concern-deployment.radical +343 -92
- package/dist/hub-catalogue/concern/concern-encryption.radical +339 -76
- package/dist/hub-catalogue/concern/concern-error-handling-logging.radical +1197 -0
- package/dist/hub-catalogue/concern/concern-eu-dora.radical +1321 -0
- package/dist/hub-catalogue/concern/concern-frontend-stack.radical +467 -160
- package/dist/hub-catalogue/concern/concern-incident-management.radical +1204 -0
- package/dist/hub-catalogue/concern/concern-infrastructure.radical +1300 -268
- package/dist/hub-catalogue/concern/concern-integration-resilience.radical +88 -51
- package/dist/hub-catalogue/concern/concern-messaging.radical +173 -140
- package/dist/hub-catalogue/concern/concern-module-boundaries.radical +162 -159
- package/dist/hub-catalogue/concern/concern-observability.radical +224 -275
- package/dist/hub-catalogue/concern/concern-operational-readiness.radical +1249 -0
- package/dist/hub-catalogue/concern/concern-personal-data.radical +637 -122
- package/dist/hub-catalogue/concern/concern-quality-priorities.radical +1091 -0
- package/dist/hub-catalogue/concern/concern-rate-limiting.radical +433 -141
- package/dist/hub-catalogue/concern/concern-release-versioning.radical +1358 -0
- package/dist/hub-catalogue/concern/concern-retention.radical +1399 -0
- package/dist/hub-catalogue/concern/concern-secrets.radical +332 -74
- package/dist/hub-catalogue/concern/concern-secure-coding.radical +1379 -0
- package/dist/hub-catalogue/concern/concern-secure-development.radical +1245 -0
- package/dist/hub-catalogue/concern/concern-security-detection.radical +1153 -0
- package/dist/hub-catalogue/concern/concern-supply-chain.radical +257 -183
- package/dist/hub-catalogue/concern/concern-technical-debt.radical +1450 -0
- package/dist/hub-catalogue/concern/concern-technology-lifecycle.radical +1145 -0
- package/dist/hub-catalogue/concern/concern-tenant-isolation.radical +271 -137
- package/dist/hub-catalogue/concern/concern-test-strategy.radical +243 -224
- package/dist/hub-catalogue/concern/concern-threat-modelling.radical +1143 -0
- package/dist/index.js +3680 -2074
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"id": "concern-capacity",
|
|
4
4
|
"category": "concern",
|
|
5
5
|
"name": "Capacity and scaling",
|
|
6
|
-
"description": "How much load it carries: the expected load and its peak, how it scales to meet it, what it does when overloaded, and how often the capacity is proven with a load test.",
|
|
6
|
+
"description": "How much load it carries: the expected load and its peak, the latency budget under load, how it scales to meet it, what it does when overloaded, and how often the capacity is proven with a load test.",
|
|
7
7
|
"tags": [
|
|
8
8
|
"reliability",
|
|
9
9
|
"performance",
|
|
@@ -17,11 +17,15 @@
|
|
|
17
17
|
"requiredMetamodel": "c4-ddd-governance-builtin",
|
|
18
18
|
"concern": {
|
|
19
19
|
"id": "capacity",
|
|
20
|
-
"trigger": "LIST NODES WHERE (type = \"container\" OR type = \"webapp\") AND external != true",
|
|
21
|
-
"why": "these elements run on capacity of their own, so the load they must carry, how they scale and what they do when overloaded has to be decided.",
|
|
22
|
-
"group": "
|
|
20
|
+
"trigger": "LIST NODES WHERE (type = \"container\" OR type = \"webapp\" OR type = \"database\" OR type = \"queue\") AND external != true",
|
|
21
|
+
"why": "these elements run on capacity of their own (instances, connections, storage, throughput), so the load they must carry, how they scale and what they do when overloaded has to be decided.",
|
|
22
|
+
"group": "operability"
|
|
23
23
|
},
|
|
24
24
|
"sources": [
|
|
25
|
+
{
|
|
26
|
+
"title": "Google SRE book, chapter 1: Introduction (capacity planning)",
|
|
27
|
+
"url": "https://sre.google/sre-book/introduction/"
|
|
28
|
+
},
|
|
25
29
|
{
|
|
26
30
|
"title": "Google SRE book, chapter 21: Handling Overload",
|
|
27
31
|
"url": "https://sre.google/sre-book/handling-overload/"
|
|
@@ -45,6 +49,18 @@
|
|
|
45
49
|
{
|
|
46
50
|
"title": "Grafana k6 documentation",
|
|
47
51
|
"url": "https://grafana.com/docs/k6/latest/"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"title": "Kubernetes documentation: Horizontal Pod Autoscaling",
|
|
55
|
+
"url": "https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"title": "RabbitMQ documentation: Queue Length Limit",
|
|
59
|
+
"url": "https://www.rabbitmq.com/docs/maxlength"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"title": "AWS Lambda documentation: function metrics",
|
|
63
|
+
"url": "https://docs.aws.amazon.com/lambda/latest/dg/monitoring-metrics-types.html"
|
|
48
64
|
}
|
|
49
65
|
],
|
|
50
66
|
"templateParams": [
|
|
@@ -56,7 +72,7 @@
|
|
|
56
72
|
"defaultValue": "horizontal",
|
|
57
73
|
"options": [
|
|
58
74
|
{
|
|
59
|
-
"value": "
|
|
75
|
+
"value": "fixed",
|
|
60
76
|
"label": "a fixed fleet sized for the peak",
|
|
61
77
|
"description": "A set number of instances (or one bigger machine) provisioned for the peak with headroom, changed by a reviewed change. Pick it when the load is predictable within a factor of 2, the element keeps state that is hard to split, or the load is small enough that autoscaling saves little."
|
|
62
78
|
},
|
|
@@ -81,17 +97,17 @@
|
|
|
81
97
|
"options": [
|
|
82
98
|
{
|
|
83
99
|
"value": "shed",
|
|
84
|
-
"label": "
|
|
100
|
+
"label": "load shedding",
|
|
85
101
|
"description": "Above a concurrency limit it refuses new requests at once (503 with Retry-After), lowest priority first, so those it accepts stay fast. Pick it for synchronous APIs and pages where a caller waits and a fast \"try again\" beats a slow timeout."
|
|
86
102
|
},
|
|
87
103
|
{
|
|
88
104
|
"value": "backpressure",
|
|
89
|
-
"label": "queue with backpressure",
|
|
90
|
-
"description": "Work goes into a bounded queue processed at the rate the workers sustain; when the queue is full, producers are
|
|
105
|
+
"label": "a bounded queue with backpressure",
|
|
106
|
+
"description": "Work goes into a bounded queue processed at the rate the workers sustain; when the queue is full, producers are refused. Pick it when the work can be done later (orders, e-mails, imports) and the caller does not wait for the result."
|
|
91
107
|
},
|
|
92
108
|
{
|
|
93
109
|
"value": "both",
|
|
94
|
-
"label": "
|
|
110
|
+
"label": "load shedding for requests and a bounded queue for work",
|
|
95
111
|
"description": "The synchronous part sheds load, the asynchronous part queues it with backpressure. Pick it when the element both answers callers and processes work in the background."
|
|
96
112
|
}
|
|
97
113
|
]
|
|
@@ -105,12 +121,12 @@
|
|
|
105
121
|
"options": [
|
|
106
122
|
{
|
|
107
123
|
"value": "release",
|
|
108
|
-
"label": "
|
|
124
|
+
"label": "a load test of every release candidate",
|
|
109
125
|
"description": "The pipeline runs a load test at the peak against a production-like environment and stops the release on a regression. Pick it when releases are frequent, an environment of production size is affordable, and performance regressions have reached users before."
|
|
110
126
|
},
|
|
111
127
|
{
|
|
112
128
|
"value": "scheduled",
|
|
113
|
-
"label": "monthly and before peak
|
|
129
|
+
"label": "a monthly load test and one before each peak event",
|
|
114
130
|
"description": "A full-scale test every month and 4 weeks before each announced peak event, finding the breaking point. Pick it when a production-size environment is costly to keep, or releases rarely change the hot paths."
|
|
115
131
|
}
|
|
116
132
|
]
|
|
@@ -132,6 +148,12 @@
|
|
|
132
148
|
"label": "Response time at the 95th percentile under load (ms)",
|
|
133
149
|
"defaultValue": "500",
|
|
134
150
|
"type": "number"
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"key": "CONCURRENCY_CAP",
|
|
154
|
+
"label": "Most concurrent connections the database (or the weakest dependency) accepts from this element. Only with horizontal or serverless scaling",
|
|
155
|
+
"defaultValue": "200",
|
|
156
|
+
"type": "number"
|
|
135
157
|
}
|
|
136
158
|
]
|
|
137
159
|
},
|
|
@@ -154,7 +176,7 @@
|
|
|
154
176
|
"y": 0,
|
|
155
177
|
"ears_type": "ubiquitous",
|
|
156
178
|
"action": "serve {{PEAK_FACTOR}} times {{EXPECTED_RPS}} requests per second, sustained for 15 minutes, with a 95th percentile response time under {{P95_MS}} ms and fewer than 0.1 % errors",
|
|
157
|
-
"rationale": "A service sized for the average fails at the peak; a load figure with a latency and error bound is what a load test can check (AWS Well-Architected REL 7)."
|
|
179
|
+
"rationale": "A service sized for the average fails at the peak; a load figure with a latency and error bound is what a load test can check (AWS Well-Architected Reliability Pillar, REL 7: design to scale with demand)."
|
|
158
180
|
},
|
|
159
181
|
{
|
|
160
182
|
"id": "req-headroom",
|
|
@@ -163,12 +185,12 @@
|
|
|
163
185
|
"x": 260,
|
|
164
186
|
"y": 130,
|
|
165
187
|
"ears_type": "state-driven",
|
|
166
|
-
"precondition": "the busiest hour of the last 7 days used more than 70 % of the provisioned CPU
|
|
167
|
-
"action": "raise the provisioned capacity by a reviewed change before the next expected peak",
|
|
168
|
-
"rationale": "A fixed fleet does not follow the load; 30 % headroom at the observed peak leaves room for growth and for an instance lost (Google SRE book,
|
|
188
|
+
"precondition": "the busiest hour of the last 7 days used more than 70 % of the provisioned CPU or memory",
|
|
189
|
+
"action": "raise a capacity alert that opens a ticket, so that the team raises the provisioned capacity by a reviewed change before the next expected peak",
|
|
190
|
+
"rationale": "A fixed fleet does not follow the load; 30 % headroom at the observed peak leaves room for growth and for an instance lost (Google SRE book, chapter 1, capacity planning).",
|
|
169
191
|
"hubWhen": {
|
|
170
192
|
"SCALING": [
|
|
171
|
-
"
|
|
193
|
+
"fixed"
|
|
172
194
|
]
|
|
173
195
|
}
|
|
174
196
|
},
|
|
@@ -180,8 +202,8 @@
|
|
|
180
202
|
"y": 260,
|
|
181
203
|
"ears_type": "event-driven",
|
|
182
204
|
"trigger": "load rises from {{EXPECTED_RPS}} to {{PEAK_FACTOR}} times {{EXPECTED_RPS}} requests per second within 5 minutes",
|
|
183
|
-
"action": "add instances, ready to serve within 3 minutes, so that the 95th percentile
|
|
184
|
-
"rationale": "Autoscaling helps only if new instances are ready before the queue grows; a slow scale-in avoids flapping (Kubernetes
|
|
205
|
+
"action": "add instances, ready to serve within 3 minutes, so that the 95th percentile stays under {{P95_MS}} ms through the ramp, and remove them only after 15 minutes below the scaling target",
|
|
206
|
+
"rationale": "Autoscaling helps only if new instances are ready before the queue grows; a slow scale-in avoids flapping (Kubernetes documentation, Horizontal Pod Autoscaling: stabilization window; AWS Well-Architected Reliability Pillar, REL 7).",
|
|
185
207
|
"hubWhen": {
|
|
186
208
|
"SCALING": [
|
|
187
209
|
"horizontal"
|
|
@@ -212,10 +234,11 @@
|
|
|
212
234
|
"y": 520,
|
|
213
235
|
"ears_type": "unwanted-behaviour",
|
|
214
236
|
"unwanted_condition": "it scales out faster than its database or another dependency accepts connections",
|
|
215
|
-
"action": "
|
|
216
|
-
"rationale": "
|
|
237
|
+
"action": "keep its connections to the dependency at or below {{CONCURRENCY_CAP}}, the dependency's limit for this element, and reach the database through a connection pooler (Amazon RDS Proxy, PgBouncer)",
|
|
238
|
+
"rationale": "An element that scales to a thousand instances opens a thousand connections; the database falls over first (Amazon Builders' Library, load shedding; Google SRE book, chapter 22).",
|
|
217
239
|
"hubWhen": {
|
|
218
240
|
"SCALING": [
|
|
241
|
+
"horizontal",
|
|
219
242
|
"serverless"
|
|
220
243
|
]
|
|
221
244
|
}
|
|
@@ -245,7 +268,7 @@
|
|
|
245
268
|
"y": 780,
|
|
246
269
|
"ears_type": "unwanted-behaviour",
|
|
247
270
|
"unwanted_condition": "its work queue reaches its bound because the workers fall behind",
|
|
248
|
-
"action": "
|
|
271
|
+
"action": "refuse new work with 429 and a Retry-After header, never drop work already accepted, send work that fails repeatedly to a dead-letter queue that is watched, and keep the backlog from growing for more than 15 minutes in a row",
|
|
249
272
|
"rationale": "An unbounded queue hides overload until memory or the wait runs out; a bound pushes the pressure back to the producer, who can wait or retry (Google SRE book, chapter 22).",
|
|
250
273
|
"hubWhen": {
|
|
251
274
|
"OVERLOAD": [
|
|
@@ -278,7 +301,7 @@
|
|
|
278
301
|
"y": 1040,
|
|
279
302
|
"ears_type": "event-driven",
|
|
280
303
|
"trigger": "30 days have passed since the last load test, or an announced peak event is 4 weeks away",
|
|
281
|
-
"action": "run a load test that ramps past {{PEAK_FACTOR}} times {{EXPECTED_RPS}} requests per second
|
|
304
|
+
"action": "run a load test that ramps past {{PEAK_FACTOR}} times {{EXPECTED_RPS}} requests per second up to 3 times the peak, fail it when the 95th percentile exceeds {{P95_MS}} ms before 1.5 times the peak, and record the band of load where it broke",
|
|
282
305
|
"rationale": "Knowing the breaking point, and keeping it 50 % above the peak, leaves time to act before a peak event instead of during it.",
|
|
283
306
|
"hubWhen": {
|
|
284
307
|
"LOADTEST": [
|
|
@@ -304,10 +327,10 @@
|
|
|
304
327
|
"y": 130,
|
|
305
328
|
"given": "a fixed fleet",
|
|
306
329
|
"when": "the weekly busiest hour uses 75 % of its CPU",
|
|
307
|
-
"then": "an alert opens a capacity
|
|
330
|
+
"then": "an alert opens a capacity ticket, and the change is merged before the next expected peak",
|
|
308
331
|
"hubWhen": {
|
|
309
332
|
"SCALING": [
|
|
310
|
-
"
|
|
333
|
+
"fixed"
|
|
311
334
|
]
|
|
312
335
|
}
|
|
313
336
|
},
|
|
@@ -317,9 +340,9 @@
|
|
|
317
340
|
"label": "Ramp to peak",
|
|
318
341
|
"x": 520,
|
|
319
342
|
"y": 260,
|
|
320
|
-
"given": "the element at {{EXPECTED_RPS}} requests per second",
|
|
343
|
+
"given": "the element at {{EXPECTED_RPS}} requests per second with a scale-down stabilization of 15 minutes",
|
|
321
344
|
"when": "load ramps to {{PEAK_FACTOR}} times that in 5 minutes",
|
|
322
|
-
"then": "
|
|
345
|
+
"then": "the 95th percentile stays under {{P95_MS}} ms through the ramp",
|
|
323
346
|
"hubWhen": {
|
|
324
347
|
"SCALING": [
|
|
325
348
|
"horizontal"
|
|
@@ -344,14 +367,15 @@
|
|
|
344
367
|
{
|
|
345
368
|
"id": "sc-downstream",
|
|
346
369
|
"type": "scenario",
|
|
347
|
-
"label": "
|
|
370
|
+
"label": "Connections capped",
|
|
348
371
|
"x": 520,
|
|
349
372
|
"y": 520,
|
|
350
|
-
"given": "a database that accepts
|
|
373
|
+
"given": "a database that accepts {{CONCURRENCY_CAP}} connections from the element",
|
|
351
374
|
"when": "load would scale the element beyond that",
|
|
352
|
-
"then": "connections stay
|
|
375
|
+
"then": "connections stay at or below {{CONCURRENCY_CAP}} and excess requests are throttled, not failed by the database",
|
|
353
376
|
"hubWhen": {
|
|
354
377
|
"SCALING": [
|
|
378
|
+
"horizontal",
|
|
355
379
|
"serverless"
|
|
356
380
|
]
|
|
357
381
|
}
|
|
@@ -380,7 +404,7 @@
|
|
|
380
404
|
"y": 780,
|
|
381
405
|
"given": "workers slower than the producers",
|
|
382
406
|
"when": "the queue reaches its bound",
|
|
383
|
-
"then": "producers get 429 with Retry-After, no accepted message is lost, and the backlog
|
|
407
|
+
"then": "producers get 429 with Retry-After, no accepted message is lost, and an alert fires if the backlog still grows after 15 minutes",
|
|
384
408
|
"hubWhen": {
|
|
385
409
|
"OVERLOAD": [
|
|
386
410
|
"backpressure",
|
|
@@ -410,8 +434,8 @@
|
|
|
410
434
|
"x": 520,
|
|
411
435
|
"y": 1040,
|
|
412
436
|
"given": "a production-size environment",
|
|
413
|
-
"when": "the monthly test ramps the load
|
|
414
|
-
"then": "the
|
|
437
|
+
"when": "the monthly test ramps the load to 3 times the peak",
|
|
438
|
+
"then": "the 95th percentile held to 1.5 times the peak, and the band where it broke is recorded",
|
|
415
439
|
"hubWhen": {
|
|
416
440
|
"LOADTEST": [
|
|
417
441
|
"scheduled"
|
|
@@ -419,7 +443,7 @@
|
|
|
419
443
|
}
|
|
420
444
|
},
|
|
421
445
|
{
|
|
422
|
-
"id": "adr-
|
|
446
|
+
"id": "adr-fixed",
|
|
423
447
|
"type": "adr",
|
|
424
448
|
"label": "Fixed fleet sized for the peak",
|
|
425
449
|
"x": 780,
|
|
@@ -427,13 +451,13 @@
|
|
|
427
451
|
"concern": "capacity",
|
|
428
452
|
"status": "accepted",
|
|
429
453
|
"date": "",
|
|
430
|
-
"context": "This element runs on capacity someone has to provide. The forces: load is not flat (a busy hour, a campaign, a sale day can be several times the usual), and a service sized for the average falls over at the peak; an overloaded service does not slow down gracefully, it queues, times out and retries until it serves nobody (a cascading failure); adding instances takes minutes and only helps when the element keeps no state of its own; whatever it calls (a database, a partner) has limits of its own that scaling out can break; idle capacity costs money every hour; and the only way to know the breaking point is to measure it before users find it.",
|
|
431
|
-
"decision": "The element runs a fixed number of instances sized so that the peak ({{PEAK_FACTOR}} times {{EXPECTED_RPS}} requests per second) uses at most 70 % of CPU, memory and connection pools, and losing one instance still carries it (N+1). Capacity changes by a reviewed change in the infrastructure code (Terraform, Pulumi, Helm values), driven by a headroom alert on the weekly busiest hour. Overload: {{OVERLOAD}}. Load tests: {{LOADTEST}}. Choose bigger instances over more of them only while the element keeps state that cannot be split; otherwise add instances.",
|
|
432
|
-
"consequences": "• Predictable cost and behaviour; nothing scales by surprise.\n• Paying for the peak all the time: at a peak factor of {{PEAK_FACTOR}}, most of the capacity idles most of the day.\n• An unexpected peak above the headroom is handled only by the overload rule, until someone adds capacity.\n•
|
|
454
|
+
"context": "This element runs on capacity someone has to provide. The forces: load is not flat (a busy hour, a campaign, a sale day can be several times the usual), and a service sized for the average falls over at the peak; an overloaded service does not slow down gracefully, it queues, times out and retries until it serves nobody (a cascading failure); adding instances takes minutes and only helps when the element keeps no state of its own; whatever it calls (a database, a partner) has limits of its own that scaling out can break; idle capacity costs money every hour; and the only way to know the breaking point is to measure it before users find it. The snippets of this pack assume the element is order-api in the shop namespace, with Prometheus, cAdvisor and kube-state-metrics on Kubernetes; rename them for yours.",
|
|
455
|
+
"decision": "The element runs a fixed number of instances sized so that the peak ({{PEAK_FACTOR}} times {{EXPECTED_RPS}} requests per second) uses at most 70 % of CPU, memory and connection pools, and losing one instance still carries it (N+1). Capacity changes by a reviewed change in the infrastructure code (Terraform, Pulumi, Helm values), driven by a headroom alert on the weekly busiest hour that opens a ticket. Overload: {{OVERLOAD}}. Load tests: {{LOADTEST}}. Choose bigger instances over more of them only while the element keeps state that cannot be split; otherwise add instances.",
|
|
456
|
+
"consequences": "• Predictable cost and behaviour; nothing scales by surprise.\n• Paying for the peak all the time: at a peak factor of {{PEAK_FACTOR}}, most of the capacity idles most of the day.\n• An unexpected peak above the headroom is handled only by the overload rule, until someone adds capacity.\n• Growing one instance has a ceiling: the largest instance type.",
|
|
433
457
|
"alternatives": "1. Horizontal autoscaling: follows the load and saves idle cost, but the element must be stateless and start fast.\n2. Serverless: no capacity to plan, but cold starts and per-request cost at steady high load.",
|
|
434
458
|
"hubWhen": {
|
|
435
459
|
"SCALING": [
|
|
436
|
-
"
|
|
460
|
+
"fixed"
|
|
437
461
|
]
|
|
438
462
|
}
|
|
439
463
|
},
|
|
@@ -446,9 +470,9 @@
|
|
|
446
470
|
"concern": "capacity",
|
|
447
471
|
"status": "accepted",
|
|
448
472
|
"date": "",
|
|
449
|
-
"context": "This element runs on capacity someone has to provide. The forces: load is not flat (a busy hour, a campaign, a sale day can be several times the usual), and a service sized for the average falls over at the peak; an overloaded service does not slow down gracefully, it queues, times out and retries until it serves nobody (a cascading failure); adding instances takes minutes and only helps when the element keeps no state of its own; whatever it calls (a database, a partner) has limits of its own that scaling out can break; idle capacity costs money every hour; and the only way to know the breaking point is to measure it before users find it.",
|
|
450
|
-
"decision": "The element runs stateless instances that the platform adds and removes: on Kubernetes, a HorizontalPodAutoscaler on CPU or on request rate (through KEDA or the Prometheus Adapter); elsewhere ECS Service Auto Scaling, Azure VM scale sets or Container Apps scale rules. Minimum replicas carry {{EXPECTED_RPS}} requests per second with one zone lost; maximum replicas carry 1.5 times the peak ({{PEAK_FACTOR}} times the normal load); scale-in waits 15 minutes. Instances start serving within 60 seconds and hold no session or file of their own. Overload: {{OVERLOAD}}. Load tests: {{LOADTEST}}. Choose the metric that rises first with load: request rate or concurrency for APIs, queue length for workers, CPU only when the work is CPU-bound.",
|
|
451
|
-
"consequences": "• Capacity follows the load; idle cost drops at night.\n• The element must be stateless and start fast; sessions and uploads live in shared stores.\n• Scaling takes minutes; a spike faster than that is met by the overload rule.\n• The maximum is a deliberate ceiling: at it, an alert asks whether to raise it or shed load.\n• Downstream limits (database connections) cap how far scaling helps.",
|
|
473
|
+
"context": "This element runs on capacity someone has to provide. The forces: load is not flat (a busy hour, a campaign, a sale day can be several times the usual), and a service sized for the average falls over at the peak; an overloaded service does not slow down gracefully, it queues, times out and retries until it serves nobody (a cascading failure); adding instances takes minutes and only helps when the element keeps no state of its own; whatever it calls (a database, a partner) has limits of its own that scaling out can break; idle capacity costs money every hour; and the only way to know the breaking point is to measure it before users find it. The snippets of this pack assume the element is order-api in the shop namespace, with Prometheus, cAdvisor and kube-state-metrics on Kubernetes; rename them for yours.",
|
|
474
|
+
"decision": "The element runs stateless instances that the platform adds and removes: on Kubernetes, a HorizontalPodAutoscaler on CPU or on request rate (through KEDA or the Prometheus Adapter); elsewhere ECS Service Auto Scaling, Azure VM scale sets or Container Apps scale rules. Minimum replicas (at least 2) carry {{EXPECTED_RPS}} requests per second with one zone lost; maximum replicas carry 1.5 times the peak ({{PEAK_FACTOR}} times the normal load) and, times the pool size per instance, stay within the {{CONCURRENCY_CAP}} connections the database accepts; scale-in waits 15 minutes. Instances start serving within 60 seconds and hold no session or file of their own. Overload: {{OVERLOAD}}. Load tests: {{LOADTEST}}. Choose the metric that rises first with load: request rate or concurrency for APIs, queue length for workers, CPU only when the work is CPU-bound.",
|
|
475
|
+
"consequences": "• Capacity follows the load; idle cost drops at night.\n• The element must be stateless and start fast; sessions and uploads live in shared stores.\n• Scaling takes minutes; a spike faster than that is met by the overload rule.\n• The maximum is a deliberate ceiling: at it, an alert asks whether to raise it or shed load.\n• Downstream limits (database connections) cap how far scaling helps; the pool size times the maximum replicas is that cap.",
|
|
452
476
|
"alternatives": "1. A fixed fleet sized for the peak: simpler, but pays for the peak all year.\n2. Serverless: scales per request to zero, at the cost of cold starts and platform limits.",
|
|
453
477
|
"hubWhen": {
|
|
454
478
|
"SCALING": [
|
|
@@ -465,9 +489,9 @@
|
|
|
465
489
|
"concern": "capacity",
|
|
466
490
|
"status": "accepted",
|
|
467
491
|
"date": "",
|
|
468
|
-
"context": "This element runs on capacity someone has to provide. The forces: load is not flat (a busy hour, a campaign, a sale day can be several times the usual), and a service sized for the average falls over at the peak; an overloaded service does not slow down gracefully, it queues, times out and retries until it serves nobody (a cascading failure); adding instances takes minutes and only helps when the element keeps no state of its own; whatever it calls (a database, a partner) has limits of its own that scaling out can break; idle capacity costs money every hour; and the only way to know the breaking point is to measure it before users find it.",
|
|
469
|
-
"decision": "The element runs on a serverless platform that starts instances per demand: AWS Lambda, Google Cloud Run, Azure Functions (Flex Consumption) or Azure Container Apps. Warm capacity (provisioned concurrency or minimum instances) carries {{EXPECTED_RPS}} requests per second; maximum concurrency is capped at what its database and other dependencies accept, with a connection pooler (Amazon RDS Proxy, PgBouncer) in front of the database. Overload: {{OVERLOAD}}. Load tests: {{LOADTEST}}. Choose the platform by request duration (Lambda up to 15 minutes; Cloud Run and Container Apps for containers and longer requests), cold start of the runtime, and cost at the steady load: above a few million requests a day, compare with containers on autoscaling.",
|
|
470
|
-
"consequences": "• No capacity to plan or idle fleet to pay for; scaling is per request.\n• Cold starts add latency at the start of every burst; warm capacity costs money.\n• Account and regional concurrency limits apply and must be raised ahead of peaks.\n• Scaling out can flood the database: the concurrency cap and the pooler are not optional.\n• Ties the element to the platform's runtime, limits and pricing.",
|
|
492
|
+
"context": "This element runs on capacity someone has to provide. The forces: load is not flat (a busy hour, a campaign, a sale day can be several times the usual), and a service sized for the average falls over at the peak; an overloaded service does not slow down gracefully, it queues, times out and retries until it serves nobody (a cascading failure); adding instances takes minutes and only helps when the element keeps no state of its own; whatever it calls (a database, a partner) has limits of its own that scaling out can break; idle capacity costs money every hour; and the only way to know the breaking point is to measure it before users find it. The snippets of this pack assume the element is order-api in the shop namespace, with Prometheus, cAdvisor and kube-state-metrics on Kubernetes; rename them for yours.",
|
|
493
|
+
"decision": "The element runs on a serverless platform that starts instances per demand: AWS Lambda, Google Cloud Run, Azure Functions (Flex Consumption) or Azure Container Apps. Warm capacity (provisioned concurrency or minimum instances) carries {{EXPECTED_RPS}} requests per second; maximum concurrency is capped at {{CONCURRENCY_CAP}}, what its database and other dependencies accept, with a connection pooler (Amazon RDS Proxy, PgBouncer) in front of the database; above the cap the platform throttles, which is the overload behaviour working. Overload: {{OVERLOAD}}. Load tests: {{LOADTEST}}. Choose the platform by request duration (Lambda up to 15 minutes; Cloud Run and Container Apps for containers and longer requests), cold start of the runtime, and cost at the steady load: above a few million requests a day, compare with containers on autoscaling.",
|
|
494
|
+
"consequences": "• No capacity to plan or idle fleet to pay for; scaling is per request.\n• Cold starts add latency at the start of every burst; warm capacity costs money.\n• Account and regional concurrency limits apply and must be raised ahead of peaks; a throttle below our own cap means that limit was hit.\n• Scaling out can flood the database: the concurrency cap and the pooler are not optional.\n• Ties the element to the platform's runtime, limits and pricing.",
|
|
471
495
|
"alternatives": "1. Containers with horizontal autoscaling: no cold starts and cheaper at steady load, but capacity to manage.\n2. A fixed fleet: predictable, but sized for a peak that rarely comes.",
|
|
472
496
|
"hubWhen": {
|
|
473
497
|
"SCALING": [
|
|
@@ -484,7 +508,7 @@
|
|
|
484
508
|
"concern": "capacity",
|
|
485
509
|
"status": "accepted",
|
|
486
510
|
"date": "",
|
|
487
|
-
"context": "This element runs on capacity someone has to provide. The forces: load is not flat (a busy hour, a campaign, a sale day can be several times the usual), and a service sized for the average falls over at the peak; an overloaded service does not slow down gracefully, it queues, times out and retries until it serves nobody (a cascading failure); adding instances takes minutes and only helps when the element keeps no state of its own; whatever it calls (a database, a partner) has limits of its own that scaling out can break; idle capacity costs money every hour; and the only way to know the breaking point is to measure it before users find it.",
|
|
511
|
+
"context": "This element runs on capacity someone has to provide. The forces: load is not flat (a busy hour, a campaign, a sale day can be several times the usual), and a service sized for the average falls over at the peak; an overloaded service does not slow down gracefully, it queues, times out and retries until it serves nobody (a cascading failure); adding instances takes minutes and only helps when the element keeps no state of its own; whatever it calls (a database, a partner) has limits of its own that scaling out can break; idle capacity costs money every hour; and the only way to know the breaking point is to measure it before users find it. The snippets of this pack assume the element is order-api in the shop namespace, with Prometheus, cAdvisor and kube-state-metrics on Kubernetes; rename them for yours.",
|
|
488
512
|
"decision": "Each instance limits the requests in flight and refuses the excess at once with 503 and Retry-After, before doing any work for it. The limit adapts to the measured latency (Envoy's adaptive concurrency filter, Netflix concurrency-limits, or the framework's own limiter such as ASP.NET Core's concurrency limiter), or is set from the load test at the knee of the latency curve. Requests carry a priority: health checks and the paying path are shed last, background and bulk calls first. Clients retry with exponential backoff and jitter, at most 3 times.",
|
|
489
513
|
"consequences": "• Accepted requests stay fast under overload; the service does not collapse.\n• Some callers see 503 at the peak; that is visible and must be explained to them.\n• The priority of each route is a product decision, written down next to the code.\n• Retries without backoff would undo it; clients are part of the design.",
|
|
490
514
|
"alternatives": "1. Unbounded queueing: no refusals, but every request slows down until all time out.\n2. Per-client rate limits only: protects against one noisy caller, not against total load.",
|
|
@@ -504,9 +528,9 @@
|
|
|
504
528
|
"concern": "capacity",
|
|
505
529
|
"status": "accepted",
|
|
506
530
|
"date": "",
|
|
507
|
-
"context": "This element runs on capacity someone has to provide. The forces: load is not flat (a busy hour, a campaign, a sale day can be several times the usual), and a service sized for the average falls over at the peak; an overloaded service does not slow down gracefully, it queues, times out and retries until it serves nobody (a cascading failure); adding instances takes minutes and only helps when the element keeps no state of its own; whatever it calls (a database, a partner) has limits of its own that scaling out can break; idle capacity costs money every hour; and the only way to know the breaking point is to measure it before users find it.",
|
|
508
|
-
"decision": "Work that the caller does not wait for goes into a bounded queue
|
|
509
|
-
"consequences": "• Peaks are absorbed by the queue and processed at a sustainable rate.\n• Results arrive later at the peak; the product must accept that delay for this work.\n• The queue length
|
|
531
|
+
"context": "This element runs on capacity someone has to provide. The forces: load is not flat (a busy hour, a campaign, a sale day can be several times the usual), and a service sized for the average falls over at the peak; an overloaded service does not slow down gracefully, it queues, times out and retries until it serves nobody (a cascading failure); adding instances takes minutes and only helps when the element keeps no state of its own; whatever it calls (a database, a partner) has limits of its own that scaling out can break; idle capacity costs money every hour; and the only way to know the breaking point is to measure it before users find it. The snippets of this pack assume the element is order-api in the shop namespace, with Prometheus, cAdvisor and kube-state-metrics on Kubernetes; rename them for yours.",
|
|
532
|
+
"decision": "Work that the caller does not wait for goes into a bounded queue. The bounded primitive is RabbitMQ with x-max-length and x-overflow reject-publish: a full queue refuses the publish, the producer's publisher confirm fails, and the producer answers 429 with Retry-After. With Amazon SQS or Kafka, which have no length bound (SQS is unbounded, Kafka is bounded by retention, not count), the producer gates itself: it reads the queue depth (ApproximateNumberOfMessages) or the consumer lag before publishing and answers 429 above the agreed bound. Workers scale on queue length or consumer lag (KEDA scalers) up to what downstream systems accept. Accepted work is never dropped; messages that fail repeatedly go to a dead-letter queue with an alert on it.",
|
|
533
|
+
"consequences": "• Peaks are absorbed by the queue and processed at a sustainable rate.\n• Results arrive later at the peak; the product must accept that delay for this work.\n• The queue length, the age of the oldest message and the dead-letter queue become the signals to watch.\n• Producers must handle 429 and retry; a producer that drops work on 429 loses it.\n• With SQS or Kafka the bound lives in the producer's code, not in the broker.",
|
|
510
534
|
"alternatives": "1. Processing everything synchronously: simple, but the caller waits and peaks hit the database directly.\n2. An unbounded queue: never refuses, but hides overload until memory or the delay is unacceptable.",
|
|
511
535
|
"hubWhen": {
|
|
512
536
|
"OVERLOAD": [
|
|
@@ -521,9 +545,12 @@
|
|
|
521
545
|
"label": "Load test gates release",
|
|
522
546
|
"x": 1040,
|
|
523
547
|
"y": 0,
|
|
524
|
-
"
|
|
525
|
-
"
|
|
526
|
-
"
|
|
548
|
+
"characteristic": "performance-efficiency",
|
|
549
|
+
"scope": "holistic",
|
|
550
|
+
"cadence": "triggered",
|
|
551
|
+
"trigger": "release",
|
|
552
|
+
"invocation": "automated",
|
|
553
|
+
"description": "The pipeline runs a k6 test against a production-like environment for every release candidate: a 5-minute ramp from the normal load to the peak (which an autoscaler has to follow in time) and 15 minutes at the peak; the thresholds fail the run, and the pipeline stops the release.\n\nThreshold: 95th percentile under {{P95_MS}} ms and errors under 0.1 % through a 5-minute ramp to {{PEAK_FACTOR}} times {{EXPECTED_RPS}} requests per second and 15 minutes at it\n\nTool: Grafana k6\n\n```js\n// k6 run --env BASE_URL=https://staging.shop.example peak.js (in the release pipeline)\nimport http from 'k6/http'\nimport { check } from 'k6'\n\nconst NORMAL = {{EXPECTED_RPS}}\nconst PEAK = NORMAL * {{PEAK_FACTOR}}\n\nexport const options = {\n scenarios: {\n peak: {\n executor: 'ramping-arrival-rate',\n startRate: NORMAL, timeUnit: '1s',\n preAllocatedVUs: 200, maxVUs: 2000,\n stages: [\n { target: PEAK, duration: '5m' }, // ramp to the peak\n { target: PEAK, duration: '15m' }, // hold it\n ],\n },\n },\n thresholds: {\n http_req_duration: ['p(95)<{{P95_MS}}'],\n http_req_failed: ['rate<0.001'],\n },\n}\n\nexport default function () {\n const res = http.get(`${__ENV.BASE_URL}/orders?page=1`)\n check(res, { 'status 200': (r) => r.status === 200 })\n}\n```",
|
|
527
554
|
"hubWhen": {
|
|
528
555
|
"LOADTEST": [
|
|
529
556
|
"release"
|
|
@@ -536,9 +563,12 @@
|
|
|
536
563
|
"label": "Breaking point measured",
|
|
537
564
|
"x": 1040,
|
|
538
565
|
"y": 130,
|
|
539
|
-
"
|
|
540
|
-
"
|
|
541
|
-
"
|
|
566
|
+
"characteristic": "performance-efficiency",
|
|
567
|
+
"scope": "holistic",
|
|
568
|
+
"cadence": "temporal",
|
|
569
|
+
"every": "30d",
|
|
570
|
+
"invocation": "automated",
|
|
571
|
+
"description": "A scheduled job runs a k6 test that ramps from the normal load past the peak to 3 times the peak, tagging requests by the band of load they were sent in. The thresholds assert the latency and error bounds up to 1.5 times the peak; the summary records the first band above it where the 95th percentile broke, as the breaking point, in a file kept with the run. The job runs monthly and 4 weeks before each announced peak event.\n\nThreshold: 95th percentile under {{P95_MS}} ms and errors under 0.1 % up to 1.5 times {{PEAK_FACTOR}} times {{EXPECTED_RPS}} requests per second; the band of load where the 95th percentile broke, up to 3 times the peak, is recorded; run at most 30 days ago\n\nTool: Grafana k6 in a scheduled job\n\n```js\n// k6 run --env BASE_URL=https://staging.shop.example breaking-point.js (monthly, and 4 weeks before a peak event)\nimport http from 'k6/http'\nimport exec from 'k6/execution'\n\nconst NORMAL = {{EXPECTED_RPS}}\nconst PEAK = NORMAL * {{PEAK_FACTOR}}\nconst STAGES = [\n { target: PEAK, minutes: 5 }, // ramp to the peak\n { target: PEAK * 1.5, minutes: 10 }, // on to 1.5 x the peak: capacity must hold here\n { target: PEAK * 3, minutes: 15 }, // on to 3 x the peak: find where it breaks\n]\nconst BANDS = ['1.5-2', '2-2.5', '2.5-3']\n\nexport const options = {\n scenarios: {\n ramp: {\n executor: 'ramping-arrival-rate', startRate: NORMAL, timeUnit: '1s', preAllocatedVUs: 500, maxVUs: 10000,\n stages: STAGES.map((s) => ({ target: s.target, duration: `${s.minutes}m` })),\n },\n },\n thresholds: {\n 'http_req_duration{band:upto1.5}': ['p(95)<{{P95_MS}}'],\n 'http_req_failed{band:upto1.5}': ['rate<0.001'],\n // the bands above 1.5 x are recorded, not asserted (a threshold makes k6 report the sub-metric)\n 'http_req_duration{band:1.5-2}': ['p(95)>=0'],\n 'http_req_duration{band:2-2.5}': ['p(95)>=0'],\n 'http_req_duration{band:2.5-3}': ['p(95)>=0'],\n },\n}\n\n/** The arrival rate at a moment of the ramp, in requests per second. */\nfunction rateAt(seconds) {\n let start = 0\n let from = NORMAL\n for (const s of STAGES) {\n const d = s.minutes * 60\n if (seconds <= start + d) return from + ((s.target - from) * (seconds - start)) / d\n start += d\n from = s.target\n }\n return from\n}\n\nexport default function () {\n const rate = rateAt(exec.instance.currentTestRunDuration / 1000)\n const band = rate <= PEAK * 1.5 ? 'upto1.5' : rate <= PEAK * 2 ? '1.5-2' : rate <= PEAK * 2.5 ? '2-2.5' : '2.5-3'\n http.get(`${__ENV.BASE_URL}/orders?page=1`, { tags: { band } })\n}\n\nexport function handleSummary(data) {\n const p95 = (band) => (data.metrics[`http_req_duration{band:${band}}`] || { values: {} }).values['p(95)']\n const broken = BANDS.find((b) => (p95(b) || 0) > {{P95_MS}})\n const line = broken ? `breaking point: between ${broken} x the peak` : 'breaking point: not reached below 3 x the peak'\n return {\n stdout: line + '\\n',\n 'breaking-point.json': JSON.stringify({ date: new Date().toISOString(), peakRps: PEAK, broken: broken || null, p95ByBand: BANDS.map((b) => [b, p95(b)]) }),\n }\n}\n```",
|
|
542
572
|
"hubWhen": {
|
|
543
573
|
"LOADTEST": [
|
|
544
574
|
"scheduled"
|
|
@@ -551,12 +581,32 @@
|
|
|
551
581
|
"label": "Headroom watched",
|
|
552
582
|
"x": 1040,
|
|
553
583
|
"y": 260,
|
|
554
|
-
"
|
|
555
|
-
"
|
|
556
|
-
"
|
|
584
|
+
"characteristic": "performance-efficiency",
|
|
585
|
+
"scope": "atomic",
|
|
586
|
+
"cadence": "continual",
|
|
587
|
+
"invocation": "automated",
|
|
588
|
+
"description": "Recording rules compute the element's CPU and memory use as a share of its requests (container-level series only, so the pod-level and pause-container series are not counted twice); an alert takes the highest hourly average of the last 7 days for each and opens a capacity ticket above 70 %.\n\nThreshold: The highest hourly average of CPU and of memory use in the last 7 days at most 70 % of what is provisioned; above it, a ticket alert\n\nTool: Prometheus recording and alerting rules (kube-state-metrics and cAdvisor metrics)\n\n```yaml\ngroups:\n - name: capacity\n rules:\n - record: order_api:cpu_use:ratio\n expr: |\n sum(rate(container_cpu_usage_seconds_total{namespace=\"shop\",pod=~\"order-api-.*\",container!=\"\",container!=\"POD\"}[5m]))\n / sum(kube_pod_container_resource_requests{namespace=\"shop\",pod=~\"order-api-.*\",resource=\"cpu\"})\n - record: order_api:memory_use:ratio\n expr: |\n sum(container_memory_working_set_bytes{namespace=\"shop\",pod=~\"order-api-.*\",container!=\"\",container!=\"POD\"})\n / sum(kube_pod_container_resource_requests{namespace=\"shop\",pod=~\"order-api-.*\",resource=\"memory\"})\n - alert: OrderApiHeadroomLow\n expr: |\n max_over_time(avg_over_time(order_api:cpu_use:ratio[1h])[7d:1h]) > 0.70\n or max_over_time(avg_over_time(order_api:memory_use:ratio[1h])[7d:1h]) > 0.70\n labels: { severity: ticket }\n annotations:\n summary: \"Order API used over 70 % of its provisioned CPU or memory at the week's busiest hour: plan a capacity change\"\n```",
|
|
589
|
+
"hubWhen": {
|
|
590
|
+
"SCALING": [
|
|
591
|
+
"fixed"
|
|
592
|
+
]
|
|
593
|
+
}
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
"id": "ff-hpa-behaviour",
|
|
597
|
+
"type": "fitness-fn",
|
|
598
|
+
"label": "Autoscaler bounds and scale-in delay",
|
|
599
|
+
"x": 1040,
|
|
600
|
+
"y": 390,
|
|
601
|
+
"characteristic": "performance-efficiency",
|
|
602
|
+
"scope": "atomic",
|
|
603
|
+
"cadence": "triggered",
|
|
604
|
+
"trigger": "pull-request",
|
|
605
|
+
"invocation": "automated",
|
|
606
|
+
"description": "A policy over the Kubernetes manifests fails the pipeline when the element's autoscaler could run a single instance, has no ceiling, or scales in sooner than 15 minutes after the load drops. ECS and Container Apps have the same three settings in their scale rules.\n\nThreshold: The HorizontalPodAutoscaler has minReplicas at least 2, maxReplicas set, and a scale-down stabilization window of at least 900 s\n\nTool: Conftest (Open Policy Agent)\n\n```rego\npackage main\n\nimport rego.v1\n\ndeny contains msg if {\n input.kind == \"HorizontalPodAutoscaler\"\n object.get(input.spec, \"minReplicas\", 1) < 2\n msg := sprintf(\"%s: minReplicas must be at least 2 (the normal load with one zone lost)\", [input.metadata.name])\n}\n\ndeny contains msg if {\n input.kind == \"HorizontalPodAutoscaler\"\n not input.spec.maxReplicas\n msg := sprintf(\"%s: set maxReplicas (1.5 x the peak, within the database's connection cap)\", [input.metadata.name])\n}\n\ndeny contains msg if {\n input.kind == \"HorizontalPodAutoscaler\"\n object.get(input.spec, [\"behavior\", \"scaleDown\", \"stabilizationWindowSeconds\"], 300) < 900\n msg := sprintf(\"%s: set behavior.scaleDown.stabilizationWindowSeconds to 900 or more\", [input.metadata.name])\n}\n```",
|
|
557
607
|
"hubWhen": {
|
|
558
608
|
"SCALING": [
|
|
559
|
-
"
|
|
609
|
+
"horizontal"
|
|
560
610
|
]
|
|
561
611
|
}
|
|
562
612
|
},
|
|
@@ -565,10 +615,30 @@
|
|
|
565
615
|
"type": "fitness-fn",
|
|
566
616
|
"label": "Autoscaling not at its ceiling",
|
|
567
617
|
"x": 1040,
|
|
568
|
-
"y":
|
|
569
|
-
"
|
|
570
|
-
"
|
|
571
|
-
"
|
|
618
|
+
"y": 520,
|
|
619
|
+
"characteristic": "performance-efficiency",
|
|
620
|
+
"scope": "atomic",
|
|
621
|
+
"cadence": "continual",
|
|
622
|
+
"invocation": "automated",
|
|
623
|
+
"description": "A Prometheus alert fires when the HorizontalPodAutoscaler has run at its maximum for 15 minutes: the ceiling is too low or the load is beyond plan, and someone decides which.\n\nThreshold: The autoscaler sits at its maximum replicas for no more than 15 minutes in a row\n\nTool: Prometheus alerting rule over kube-state-metrics\n\n```yaml\ngroups:\n - name: autoscaling\n rules:\n - alert: OrderApiAtMaxReplicas\n expr: |\n kube_horizontalpodautoscaler_status_current_replicas{namespace=\"shop\",horizontalpodautoscaler=\"order-api\"}\n >= kube_horizontalpodautoscaler_spec_max_replicas{namespace=\"shop\",horizontalpodautoscaler=\"order-api\"}\n for: 15m\n labels: { severity: page }\n annotations:\n summary: \"Order API has been at its maximum replicas for 15 minutes\"\n```",
|
|
624
|
+
"hubWhen": {
|
|
625
|
+
"SCALING": [
|
|
626
|
+
"horizontal"
|
|
627
|
+
]
|
|
628
|
+
}
|
|
629
|
+
},
|
|
630
|
+
{
|
|
631
|
+
"id": "ff-pool-cap",
|
|
632
|
+
"type": "fitness-fn",
|
|
633
|
+
"label": "Replicas times pool size within the cap",
|
|
634
|
+
"x": 1040,
|
|
635
|
+
"y": 650,
|
|
636
|
+
"characteristic": "performance-efficiency",
|
|
637
|
+
"scope": "atomic",
|
|
638
|
+
"cadence": "triggered",
|
|
639
|
+
"trigger": "pull-request",
|
|
640
|
+
"invocation": "automated",
|
|
641
|
+
"description": "A policy over the Kubernetes manifests, run with conftest --combine so that it sees the autoscaler and the Deployment together, fails the pipeline when the most instances the autoscaler may run, times the pool size each is configured with, exceeds what the database accepts from the element.\n\nThreshold: maxReplicas of the autoscaler times the connection pool size per instance (DB_POOL_SIZE) is at most {{CONCURRENCY_CAP}}\n\nTool: Conftest (Open Policy Agent), conftest test --combine k8s/\n\n```rego\npackage main\n\nimport rego.v1\n\ndeny contains msg if {\n some hpa in input\n hpa.contents.kind == \"HorizontalPodAutoscaler\"\n some dep in input\n dep.contents.kind == \"Deployment\"\n dep.contents.metadata.name == hpa.contents.spec.scaleTargetRef.name\n some c in dep.contents.spec.template.spec.containers\n some e in c.env\n e.name == \"DB_POOL_SIZE\"\n connections := hpa.contents.spec.maxReplicas * to_number(e.value)\n connections > {{CONCURRENCY_CAP}}\n msg := sprintf(\"%s: %d replicas x pool %s = %d connections, above the cap the database accepts\", [dep.contents.metadata.name, hpa.contents.spec.maxReplicas, e.value, connections])\n}\n```",
|
|
572
642
|
"hubWhen": {
|
|
573
643
|
"SCALING": [
|
|
574
644
|
"horizontal"
|
|
@@ -578,12 +648,32 @@
|
|
|
578
648
|
{
|
|
579
649
|
"id": "ff-serverless-throttles",
|
|
580
650
|
"type": "fitness-fn",
|
|
581
|
-
"label": "
|
|
651
|
+
"label": "Throttled only at our cap",
|
|
582
652
|
"x": 1040,
|
|
583
|
-
"y":
|
|
584
|
-
"
|
|
585
|
-
"
|
|
586
|
-
"
|
|
653
|
+
"y": 780,
|
|
654
|
+
"characteristic": "performance-efficiency",
|
|
655
|
+
"scope": "atomic",
|
|
656
|
+
"cadence": "continual",
|
|
657
|
+
"invocation": "automated",
|
|
658
|
+
"description": "The function's reserved concurrency is the cap; throttling at it is the overload rule working. Two CloudWatch alarms in Terraform: one on concurrent executions sustained above 80 % of the cap (raise the cap, or the database's limit), and one on throttles that happen while concurrency is still under 90 % of the cap, which means the account or region limit throttled first and must be raised. Cloud Run and Azure Functions expose the same two metrics in Cloud Monitoring and Azure Monitor.\n\nThreshold: 0 throttled invocations in any 5 minutes while concurrency is under 90 % of {{CONCURRENCY_CAP}}; concurrency under 80 % of {{CONCURRENCY_CAP}} for all but 5 minutes\n\nTool: Amazon CloudWatch alarms in Terraform (metric math)\n\n```hcl\nresource \"aws_lambda_function\" \"order_api\" {\n function_name = \"order-api\"\n # ...\n reserved_concurrent_executions = {{CONCURRENCY_CAP}} # what the database accepts through the pooler\n}\n\nresource \"aws_cloudwatch_metric_alarm\" \"order_api_concurrency_near_cap\" {\n alarm_name = \"order-api-concurrency-80pct\"\n namespace = \"AWS/Lambda\"\n metric_name = \"ConcurrentExecutions\"\n dimensions = { FunctionName = aws_lambda_function.order_api.function_name }\n statistic = \"Maximum\"\n period = 60\n evaluation_periods = 5\n threshold = {{CONCURRENCY_CAP}} * 0.8\n comparison_operator = \"GreaterThanThreshold\"\n}\n\nresource \"aws_cloudwatch_metric_alarm\" \"order_api_throttled_below_cap\" {\n alarm_name = \"order-api-throttled-below-cap\"\n comparison_operator = \"GreaterThanThreshold\"\n threshold = 0\n evaluation_periods = 1\n treat_missing_data = \"notBreaching\"\n metric_query {\n id = \"below_cap\"\n expression = \"IF(concurrency < {{CONCURRENCY_CAP}} * 0.9, throttles, 0)\"\n label = \"throttles while under 90 % of our cap: the account limit throttled, not us\"\n return_data = true\n }\n metric_query {\n id = \"throttles\"\n metric {\n namespace = \"AWS/Lambda\"\n metric_name = \"Throttles\"\n period = 300\n stat = \"Sum\"\n dimensions = { FunctionName = aws_lambda_function.order_api.function_name }\n }\n }\n metric_query {\n id = \"concurrency\"\n metric {\n namespace = \"AWS/Lambda\"\n metric_name = \"ConcurrentExecutions\"\n period = 300\n stat = \"Maximum\"\n dimensions = { FunctionName = aws_lambda_function.order_api.function_name }\n }\n }\n}\n```",
|
|
659
|
+
"hubWhen": {
|
|
660
|
+
"SCALING": [
|
|
661
|
+
"serverless"
|
|
662
|
+
]
|
|
663
|
+
}
|
|
664
|
+
},
|
|
665
|
+
{
|
|
666
|
+
"id": "ff-cold-start",
|
|
667
|
+
"type": "fitness-fn",
|
|
668
|
+
"label": "Burst after idle answered in time",
|
|
669
|
+
"x": 1040,
|
|
670
|
+
"y": 910,
|
|
671
|
+
"characteristic": "performance-efficiency",
|
|
672
|
+
"scope": "holistic",
|
|
673
|
+
"cadence": "triggered",
|
|
674
|
+
"trigger": "nightly",
|
|
675
|
+
"invocation": "automated",
|
|
676
|
+
"description": "A nightly job waits until the element has been idle at its minimum instances for 15 minutes, then runs a k6 burst at the peak rate; the slowest request, cold starts included, must answer within a second. On AWS, the InitDuration in the function's logs says how much of it was the start.\n\nThreshold: After 15 idle minutes, a 2-minute burst at {{PEAK_FACTOR}} times {{EXPECTED_RPS}} requests per second has every request answered within 1000 ms and fewer than 0.1 % errors\n\nTool: Grafana k6 in a scheduled job\n\n```js\n// k6 run --env BASE_URL=https://staging.shop.example cold-start.js (nightly, after 15 idle minutes)\nimport http from 'k6/http'\n\nexport const options = {\n scenarios: {\n burst: { executor: 'constant-arrival-rate', rate: {{PEAK_FACTOR}} * {{EXPECTED_RPS}}, timeUnit: '1s', duration: '2m', preAllocatedVUs: 500, maxVUs: 5000 },\n },\n thresholds: {\n http_req_duration: ['max<1000'], // the slowest request, cold start included\n http_req_failed: ['rate<0.001'],\n },\n}\n\nexport default function () {\n http.get(`${__ENV.BASE_URL}/orders?page=1`)\n}\n```",
|
|
587
677
|
"hubWhen": {
|
|
588
678
|
"SCALING": [
|
|
589
679
|
"serverless"
|
|
@@ -595,10 +685,13 @@
|
|
|
595
685
|
"type": "fitness-fn",
|
|
596
686
|
"label": "Overload is shed fast",
|
|
597
687
|
"x": 1040,
|
|
598
|
-
"y":
|
|
599
|
-
"
|
|
600
|
-
"
|
|
601
|
-
"
|
|
688
|
+
"y": 1040,
|
|
689
|
+
"characteristic": "reliability",
|
|
690
|
+
"scope": "holistic",
|
|
691
|
+
"cadence": "triggered",
|
|
692
|
+
"trigger": "release",
|
|
693
|
+
"invocation": "automated",
|
|
694
|
+
"description": "A k6 overload test drives twice the peak and checks two things separately: refusals are fast 503s, and the requests that were accepted kept their latency. A service that slows everything down instead fails the test.\n\nThreshold: At twice the peak: refused requests answered with 503 in under 50 ms (95th percentile), accepted ones under {{P95_MS}} ms, and nothing but 200 or 503\n\nTool: Grafana k6\n\n```js\nimport http from 'k6/http'\nimport { Trend } from 'k6/metrics'\n\nconst accepted = new Trend('accepted_duration', true)\nconst refused = new Trend('refused_duration', true)\n\nexport const options = {\n scenarios: {\n overload: { executor: 'constant-arrival-rate', rate: 2 * {{PEAK_FACTOR}} * {{EXPECTED_RPS}}, timeUnit: '1s',\n duration: '10m', preAllocatedVUs: 500, maxVUs: 5000 },\n },\n thresholds: {\n accepted_duration: ['p(95)<{{P95_MS}}'],\n refused_duration: ['p(95)<50'],\n http_req_failed: ['rate<0.001'], // anything but 200 or 503\n },\n}\n\nhttp.setResponseCallback(http.expectedStatuses(200, 503))\n\nexport default function () {\n const res = http.get(`${__ENV.BASE_URL}/orders?page=1`)\n ;(res.status === 503 ? refused : accepted).add(res.timings.duration)\n}\n```",
|
|
602
695
|
"hubWhen": {
|
|
603
696
|
"OVERLOAD": [
|
|
604
697
|
"shed",
|
|
@@ -609,12 +702,14 @@
|
|
|
609
702
|
{
|
|
610
703
|
"id": "ff-backlog",
|
|
611
704
|
"type": "fitness-fn",
|
|
612
|
-
"label": "Backlog drains",
|
|
705
|
+
"label": "Backlog drains, dead letters seen",
|
|
613
706
|
"x": 1040,
|
|
614
|
-
"y":
|
|
615
|
-
"
|
|
616
|
-
"
|
|
617
|
-
"
|
|
707
|
+
"y": 1170,
|
|
708
|
+
"characteristic": "performance-efficiency",
|
|
709
|
+
"scope": "atomic",
|
|
710
|
+
"cadence": "continual",
|
|
711
|
+
"invocation": "automated",
|
|
712
|
+
"description": "Two Prometheus alerts over RabbitMQ's per-queue metrics: one fires when the work queue has kept growing for 15 minutes, meaning the workers cannot keep up even after scaling; the other opens a ticket when the dead-letter queue is not empty. The queue is declared with x-max-length and x-overflow reject-publish, so a full queue refuses the publish. With Kafka the first rule reads kafka_consumergroup_lag from kafka_exporter; with SQS, ApproximateAgeOfOldestMessage in CloudWatch.\n\nThreshold: The queue's ready messages grow for no more than 15 minutes in a row; the dead-letter queue holds messages for no more than 5 minutes before a ticket\n\nTool: Prometheus alerting rules over the RabbitMQ Prometheus plugin (/metrics/detailed, family queue_coarse_metrics)\n\n```yaml\n# prometheus.yml: scrape the per-queue metrics\n# - job_name: rabbitmq-queues\n# metrics_path: /metrics/detailed\n# params: { family: [queue_coarse_metrics] }\n# static_configs: [{ targets: [\"rabbitmq.shop:15692\"] }]\ngroups:\n - name: backpressure\n rules:\n - alert: OrderWorkersFallingBehind\n expr: deriv(sum(rabbitmq_detailed_queue_messages_ready{queue=\"orders\"})[15m:1m]) > 0\n for: 15m\n labels: { severity: page }\n annotations:\n summary: \"The orders queue has grown for 15 minutes: workers cannot keep up even after scaling\"\n - alert: OrderDeadLetters\n expr: sum(rabbitmq_detailed_queue_messages_ready{queue=\"orders.dlq\"}) > 0\n for: 5m\n labels: { severity: ticket }\n annotations:\n summary: \"Messages in the orders dead-letter queue: work that failed repeatedly needs a look\"\n```",
|
|
618
713
|
"hubWhen": {
|
|
619
714
|
"OVERLOAD": [
|
|
620
715
|
"backpressure",
|
|
@@ -733,9 +828,9 @@
|
|
|
733
828
|
"relationType": "verifies"
|
|
734
829
|
},
|
|
735
830
|
{
|
|
736
|
-
"id": "ff-loadtest-release--implements--adr-
|
|
831
|
+
"id": "ff-loadtest-release--implements--adr-fixed",
|
|
737
832
|
"sourceId": "ff-loadtest-release",
|
|
738
|
-
"targetId": "adr-
|
|
833
|
+
"targetId": "adr-fixed",
|
|
739
834
|
"relationType": "implements"
|
|
740
835
|
},
|
|
741
836
|
{
|
|
@@ -751,9 +846,9 @@
|
|
|
751
846
|
"relationType": "implements"
|
|
752
847
|
},
|
|
753
848
|
{
|
|
754
|
-
"id": "ff-loadtest-scheduled--implements--adr-
|
|
849
|
+
"id": "ff-loadtest-scheduled--implements--adr-fixed",
|
|
755
850
|
"sourceId": "ff-loadtest-scheduled",
|
|
756
|
-
"targetId": "adr-
|
|
851
|
+
"targetId": "adr-fixed",
|
|
757
852
|
"relationType": "implements"
|
|
758
853
|
},
|
|
759
854
|
{
|
|
@@ -769,9 +864,15 @@
|
|
|
769
864
|
"relationType": "implements"
|
|
770
865
|
},
|
|
771
866
|
{
|
|
772
|
-
"id": "ff-headroom--implements--adr-
|
|
867
|
+
"id": "ff-headroom--implements--adr-fixed",
|
|
773
868
|
"sourceId": "ff-headroom",
|
|
774
|
-
"targetId": "adr-
|
|
869
|
+
"targetId": "adr-fixed",
|
|
870
|
+
"relationType": "implements"
|
|
871
|
+
},
|
|
872
|
+
{
|
|
873
|
+
"id": "ff-hpa-behaviour--implements--adr-autoscale",
|
|
874
|
+
"sourceId": "ff-hpa-behaviour",
|
|
875
|
+
"targetId": "adr-autoscale",
|
|
775
876
|
"relationType": "implements"
|
|
776
877
|
},
|
|
777
878
|
{
|
|
@@ -780,12 +881,24 @@
|
|
|
780
881
|
"targetId": "adr-autoscale",
|
|
781
882
|
"relationType": "implements"
|
|
782
883
|
},
|
|
884
|
+
{
|
|
885
|
+
"id": "ff-pool-cap--implements--adr-autoscale",
|
|
886
|
+
"sourceId": "ff-pool-cap",
|
|
887
|
+
"targetId": "adr-autoscale",
|
|
888
|
+
"relationType": "implements"
|
|
889
|
+
},
|
|
783
890
|
{
|
|
784
891
|
"id": "ff-serverless-throttles--implements--adr-serverless",
|
|
785
892
|
"sourceId": "ff-serverless-throttles",
|
|
786
893
|
"targetId": "adr-serverless",
|
|
787
894
|
"relationType": "implements"
|
|
788
895
|
},
|
|
896
|
+
{
|
|
897
|
+
"id": "ff-cold-start--implements--adr-serverless",
|
|
898
|
+
"sourceId": "ff-cold-start",
|
|
899
|
+
"targetId": "adr-serverless",
|
|
900
|
+
"relationType": "implements"
|
|
901
|
+
},
|
|
789
902
|
{
|
|
790
903
|
"id": "ff-shed--implements--adr-shed",
|
|
791
904
|
"sourceId": "ff-shed",
|