vybekiit 0.7.0 → 0.7.2

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.
Files changed (94) hide show
  1. package/dist/bin.js +1697 -562
  2. package/dist/global-skills/add-ai/SKILL.md +1 -1
  3. package/dist/global-skills/add-analytics/SKILL.md +1 -1
  4. package/dist/global-skills/add-blog/SKILL.md +1 -1
  5. package/dist/global-skills/add-crud/SKILL.md +1 -1
  6. package/dist/global-skills/add-files/SKILL.md +1 -1
  7. package/dist/global-skills/add-images/SKILL.md +1 -1
  8. package/dist/global-skills/add-language/SKILL.md +1 -1
  9. package/dist/global-skills/add-notifications/SKILL.md +1 -1
  10. package/dist/global-skills/add-realtime/SKILL.md +1 -1
  11. package/dist/global-skills/add-route/SKILL.md +1 -1
  12. package/dist/global-skills/add-search/SKILL.md +1 -1
  13. package/dist/global-skills/add-signin/SKILL.md +1 -1
  14. package/dist/global-skills/add-teams/SKILL.md +1 -1
  15. package/dist/global-skills/add-upload/SKILL.md +1 -1
  16. package/dist/global-skills/aws-serverless/SKILL.md +44 -44
  17. package/dist/global-skills/aws-serverless/assets/powertools-handler.py +1 -2
  18. package/dist/global-skills/aws-serverless/references/api-gateway.md +470 -50
  19. package/dist/global-skills/aws-serverless/references/architecture.md +186 -47
  20. package/dist/global-skills/aws-serverless/references/concurrency.md +158 -44
  21. package/dist/global-skills/aws-serverless/references/deployment.md +1 -1
  22. package/dist/global-skills/aws-serverless/references/event-sources.md +391 -72
  23. package/dist/global-skills/aws-serverless/references/lambda.md +428 -69
  24. package/dist/global-skills/aws-serverless/references/orchestration.md +384 -65
  25. package/dist/global-skills/aws-serverless/references/production.md +415 -78
  26. package/dist/global-skills/aws-serverless/references/troubleshooting.md +626 -79
  27. package/dist/global-skills/back-up-my-code/SKILL.md +1 -1
  28. package/dist/global-skills/buy-domain/SKILL.md +1 -1
  29. package/dist/global-skills/check-safety/SKILL.md +1 -1
  30. package/dist/global-skills/configure-capabilities/SKILL.md +1 -1
  31. package/dist/global-skills/connect-account/SKILL.md +1 -1
  32. package/dist/global-skills/connect-account-backend/SKILL.md +1 -1
  33. package/dist/global-skills/design-my-data/SKILL.md +1 -1
  34. package/dist/global-skills/doctor/SKILL.md +1 -1
  35. package/dist/global-skills/feedback/SKILL.md +63 -0
  36. package/dist/global-skills/go-live/SKILL.md +1 -1
  37. package/dist/global-skills/harden/SKILL.md +1 -1
  38. package/dist/global-skills/instrument-feature-flags/references/usage.md +0 -35
  39. package/dist/global-skills/instrument-product-analytics/SKILL.md +1 -1
  40. package/dist/global-skills/instrument-product-analytics/references/android.md +0 -36
  41. package/dist/global-skills/instrument-product-analytics/references/configuration.md +0 -1
  42. package/dist/global-skills/instrument-product-analytics/references/flutter.md +0 -37
  43. package/dist/global-skills/instrument-product-analytics/references/posthog-python.md +2 -3
  44. package/dist/global-skills/instrument-product-analytics/references/usage.md +0 -35
  45. package/dist/global-skills/manifest.json +2 -1
  46. package/dist/global-skills/neon/SKILL.md +20 -27
  47. package/dist/global-skills/neon-ai-gateway/SKILL.md +2 -68
  48. package/dist/global-skills/neon-functions/SKILL.md +7 -7
  49. package/dist/global-skills/neon-object-storage/SKILL.md +2 -2
  50. package/dist/global-skills/neon-postgres/SKILL.md +5 -5
  51. package/dist/global-skills/neon-postgres-branches/SKILL.md +1 -1
  52. package/dist/global-skills/onboarding/SKILL.md +1 -1
  53. package/dist/global-skills/plan-my-idea/SKILL.md +1 -1
  54. package/dist/global-skills/publish-app/SKILL.md +1 -1
  55. package/dist/global-skills/publish-extension/SKILL.md +1 -1
  56. package/dist/global-skills/reset-password/SKILL.md +1 -1
  57. package/dist/global-skills/save-data/SKILL.md +1 -1
  58. package/dist/global-skills/setup-email/SKILL.md +1 -1
  59. package/dist/global-skills/setup-payments/SKILL.md +1 -1
  60. package/dist/global-skills/setup-sms/SKILL.md +1 -1
  61. package/dist/global-skills/sign-in-with-email-link/SKILL.md +1 -1
  62. package/dist/global-skills/sign-in-with-google/SKILL.md +1 -1
  63. package/dist/global-skills/sign-in-with-phone/SKILL.md +1 -1
  64. package/dist/global-skills/stripe-best-practices/SKILL.md +6 -11
  65. package/dist/global-skills/stripe-best-practices/references/billing.md +0 -5
  66. package/dist/global-skills/stripe-best-practices/references/payments.md +2 -4
  67. package/dist/global-skills/stripe-best-practices/references/tax.md +8 -78
  68. package/dist/global-skills/track-errors/SKILL.md +1 -1
  69. package/dist/global-skills/update-kit/SKILL.md +1 -1
  70. package/dist/global-skills/wire-auth/SKILL.md +1 -1
  71. package/dist/global-skills/wire-database/SKILL.md +1 -1
  72. package/dist/global-skills/wire-email/SKILL.md +1 -1
  73. package/dist/global-skills/wire-payments/SKILL.md +1 -1
  74. package/package.json +8 -8
  75. package/dist/global-skills/email-best-practices/.github/workflows/sync-skills.yml +0 -30
  76. package/dist/global-skills/email-best-practices/README.md +0 -63
  77. package/dist/global-skills/email-best-practices/references/accessibility.md +0 -189
  78. package/dist/global-skills/email-best-practices/references/compliance.md +0 -125
  79. package/dist/global-skills/email-best-practices/references/deliverability.md +0 -121
  80. package/dist/global-skills/email-best-practices/references/email-capture.md +0 -129
  81. package/dist/global-skills/email-best-practices/references/email-types.md +0 -173
  82. package/dist/global-skills/email-best-practices/references/list-management.md +0 -157
  83. package/dist/global-skills/email-best-practices/references/marketing-emails.md +0 -115
  84. package/dist/global-skills/email-best-practices/references/sending-reliability.md +0 -155
  85. package/dist/global-skills/email-best-practices/references/transactional-email-catalog.md +0 -418
  86. package/dist/global-skills/email-best-practices/references/transactional-emails.md +0 -92
  87. package/dist/global-skills/email-best-practices/references/webhooks-events.md +0 -167
  88. package/dist/global-skills/email-best-practices/tests/README.md +0 -35
  89. package/dist/global-skills/email-best-practices/tests/scenarios/01-spam-deliverability.md +0 -46
  90. package/dist/global-skills/email-best-practices/tests/scenarios/02-multi-region-compliance.md +0 -48
  91. package/dist/global-skills/email-best-practices/tests/scenarios/03-retry-idempotency.md +0 -36
  92. package/dist/global-skills/email-best-practices/tests/scenarios/04-webhook-bounce-handling.md +0 -52
  93. package/dist/global-skills/email-best-practices/tests/scenarios/05-new-saas-email-plan.md +0 -51
  94. package/dist/global-skills/neon-postgres/references/neon-sdk.md +0 -262
@@ -1,123 +1,262 @@
1
1
  # Serverless Architecture Patterns
2
2
 
3
- Pattern selection and the opinionated service defaults / constraints for each. The patterns themselves are standard — the value here is the default-vs-alternative choices and the non-obvious constraints.
3
+ Reference architectures, pattern selection flowcharts, and service selection tables for common serverless workloads.
4
4
 
5
- ## Pattern selection
5
+ ## Contents
6
6
 
7
- | What you're building | Pattern |
8
- |---|---|
9
- | Synchronous request/response API | REST/HTTP API → Lambda → DynamoDB |
10
- | Processing events from a queue/stream/database | Event processing (SQS/Streams → Lambda) |
11
- | Multi-step workflow with branching/error handling | Orchestration (Step Functions) |
12
- | Real-time bidirectional / LLM streaming | WebSocket API or Function URL streaming |
13
- | One event → multiple independent consumers | Async fan-out (EventBridge / SNS) |
14
- | Recurring task on a schedule | EventBridge Scheduler → Lambda / Step Functions |
7
+ - [Pattern selection flowchart](#pattern-selection-flowchart)
8
+ - [REST/HTTP API pattern](#resthttp-api-pattern)
9
+ - [Event processing pattern](#event-processing-pattern)
10
+ - [Orchestration pattern](#orchestration-pattern)
11
+ - [Real-time streaming pattern](#real-time-streaming-pattern)
12
+ - [Async fan-out pattern](#async-fan-out-pattern)
13
+ - [Scheduled jobs pattern](#scheduled-jobs-pattern)
14
+ - [Choosing between patterns](#choosing-between-patterns)
15
+
16
+ ---
15
17
 
16
- Most real apps combine several. Start with one (a CRUD API on DynamoDB covers most initial needs); add event processing for async work, orchestration for multi-step workflows, fan-out for cross-service comms.
18
+ ## Pattern selection flowchart
19
+
20
+ ```
21
+ What are you building?
22
+
23
+ ├── Synchronous request/response API?
24
+ │ └── REST/HTTP API pattern
25
+
26
+ ├── Processing events from a queue/stream/database?
27
+ │ └── Event processing pattern
28
+
29
+ ├── Multi-step workflow with branching/error handling?
30
+ │ └── Orchestration pattern
31
+
32
+ ├── Real-time bidirectional communication or LLM streaming?
33
+ │ └── Real-time streaming pattern
34
+
35
+ ├── One event triggers multiple independent consumers?
36
+ │ └── Async fan-out pattern
37
+
38
+ └── Recurring task on a schedule?
39
+ └── Scheduled jobs pattern
40
+ ```
17
41
 
18
42
  ---
19
43
 
20
44
  ## REST/HTTP API pattern
21
45
 
22
- CRUD APIs, mobile/web backends, microservices.
46
+ ```
47
+ Client → API Gateway (HTTP API) → Lambda → DynamoDB
48
+ → S3 (binary storage)
49
+ ```
50
+
51
+ **When:** CRUD APIs, mobile/web backends, microservices.
52
+
53
+ **Service selection:**
23
54
 
24
55
  | Decision | Default | Alternative |
25
56
  |---|---|---|
26
- | API type | HTTP API (simpler) | REST API for WAF, caching, request validation, API keys |
27
- | Auth | JWT authorizer (HTTP API native) | Cognito (REST native), Lambda authorizer (custom logic) |
28
- | Database | DynamoDB (on-demand) | RDS Proxy + RDS for relational data |
29
- | File storage | S3 presigned URLs | Direct upload via API Gateway (10 MB limit) |
30
- | Function pattern | One function per route | Lambdalith for Express/FastAPI migrations |
57
+ | API type | HTTP API (simpler) | REST API if you need WAF, caching, request validation, API keys |
58
+ | Auth | JWT authorizer (HTTP API native) | Cognito (REST: native Cognito authorizer; HTTP: JWT authorizer), Lambda authorizer (custom logic) |
59
+ | Database | DynamoDB (on-demand) | RDS Proxy + RDS if relational data needed |
60
+ | File storage | S3 with presigned URLs | Direct upload via API Gateway (10 MB limit) |
61
+ | Function pattern | One function per route | Lambdalith if team prefers Express/FastAPI style |
62
+
63
+ **Key constraints:**
31
64
 
32
- Constraints: HTTP API 30s hard timeout, no WAF/caching; REST API 29s default (adjustable for Regional/private). Both 10 MB payload.
65
+ - HTTP API: 30s hard timeout, no WAF, no caching, 10 MB payload
66
+ - REST API: 29s default timeout (adjustable for Regional/private APIs), 10 MB payload
33
67
 
34
68
  ---
35
69
 
36
70
  ## Event processing pattern
37
71
 
38
- Async workloads, decoupled producers/consumers, batch/file processing.
72
+ ```
73
+ Event source → SQS → Lambda → DynamoDB / S3
74
+
75
+ DLQ (failed messages)
76
+ ```
77
+
78
+ **When:** Async workloads, decoupled producers/consumers, batch processing, file processing.
79
+
80
+ **Service selection:**
39
81
 
40
82
  | Decision | Default | Alternative |
41
83
  |---|---|---|
42
- | Buffer | SQS standard | SQS FIFO if ordering matters (10-msg batch) |
43
- | Trigger | SQS ESM | S3 event notification → Lambda (file uploads) |
44
- | Change data capture | DynamoDB Streams → Lambda | EventBridge Pipes → Lambda (no ESM) |
84
+ | Buffer | SQS standard queue | SQS FIFO if ordering matters (10 msg batch limit) |
85
+ | Trigger | SQS event source mapping | S3 event notification → Lambda (file uploads) |
86
+ | Change data capture | DynamoDB Streams → Lambda | EventBridge Pipes → Lambda (no ESM needed) |
45
87
  | Stream ingestion | SQS (simpler) | Kinesis (ordered replay, multiple consumers, high-throughput) |
46
- | Error handling | SQS redrive policy (DLQ) | On-failure destination for streams |
47
- | Concurrency control | `MaximumConcurrency` on ESM | Reserved concurrency on function |
88
+ | Error handling | SQS redrive policy (DLQ) | On-failure destination (SQS/SNS/S3) for streams |
89
+ | Concurrency control | MaximumConcurrency on ESM | Reserved concurrency on function |
90
+ | Batch processing | ReportBatchItemFailures | Powertools Batch Processor utility |
48
91
 
49
- Constraints: SQS visibility ≥ 6× function timeout; `MaximumConcurrency` and Provisioned Mode mutually exclusive on one ESM; SQS filter drops unmatched messages permanently. **S3 triggers:** never write output to the triggering bucket/prefix (recursion); no native DLQ (use Lambda async DLQ); consider EventBridge for S3 (richer filtering). **DynamoDB Streams:** max 2 consumers/shard, 24h retention, ordering per partition key only.
92
+ **Key constraints:**
93
+
94
+ - SQS visibility timeout ≥ 6× function timeout
95
+ - MaximumConcurrency and Provisioned Mode are mutually exclusive on same ESM
96
+ - Enable partial batch failure reporting to avoid reprocessing successful messages
97
+ - SQS event filtering automatically deletes unmatched messages (permanently — not sent to DLQ)
98
+
99
+ **S3 trigger constraints:**
100
+
101
+ - Recursive invocation risk: never write output to the same bucket/prefix that triggers the function
102
+ - No native DLQ on S3 notifications — use Lambda async invocation DLQ instead
103
+ - Use prefix/suffix filtering to limit which objects trigger the function
104
+ - Consider EventBridge for S3 instead of S3 notifications (richer filtering, multiple targets)
105
+
106
+ **DynamoDB Streams constraints:**
107
+
108
+ - Max 2 Lambda consumers per stream shard (use EventBridge Pipes for more)
109
+ - 24-hour stream retention — records expire and cannot be replayed after that
110
+ - Ordering guaranteed per partition key, not globally
50
111
 
51
112
  ---
52
113
 
53
114
  ## Orchestration pattern
54
115
 
55
- Multi-step workflows, saga transactions, approval chains, data pipelines, AI agent loops.
116
+ ```
117
+ Trigger → Step Functions → Lambda (validate)
118
+ → Choice (route by status)
119
+ → Parallel (fan-out)
120
+ → Lambda (aggregate) → DynamoDB
121
+ ```
122
+
123
+ **When:** Multi-step workflows, saga transactions, approval chains, data pipelines, AI agent loops.
124
+
125
+ **Service selection:**
56
126
 
57
127
  | Decision | Default | Alternative |
58
128
  |---|---|---|
59
- | Workflow type | Standard (exactly-once, 1 year) | Express (< 5 min, high-volume) |
60
- | Simple transforms | JSONata (inline, no Lambda) | Lambda task (complex logic) |
129
+ | Workflow type | Standard (exactly-once, up to 1 year) | Express (<5 min, high-volume; async=at-least-once, sync=at-most-once) |
130
+ | Simple data transforms | JSONata (inline, no Lambda needed) | Lambda task (complex logic) |
61
131
  | Service calls | Direct SDK integration (200+ services) | Lambda intermediary (only if business logic needed) |
62
- | Human approval | `.waitForTaskToken` | Lambda durable functions `waitForCallback` |
132
+ | Human approval | .waitForTaskToken | Lambda durable functions waitForCallback |
63
133
  | AI agent loops | Step Functions + Bedrock | Lambda durable functions (code-first, checkpointed) |
134
+ | Error handling | Retry + Catch in ASL | Lambda durable functions try/catch in code |
135
+
136
+ **Key constraints:**
64
137
 
65
- Constraints: 256 KiB between states (use S3 for large data); Express lacks `.sync`/`.waitForTaskToken`/Distributed Map/Activities; 25,000 history entries (Standard). See [orchestration.md](orchestration.md).
138
+ - 256 KB payload limit between states use S3 for large data
139
+ - Express: no .sync, no .waitForTaskToken, no Distributed Map, no Activities
140
+ - 25,000 execution history entries (Standard) — split long workflows into child executions
141
+ - Prefer direct SDK integrations over Lambda intermediary functions to reduce latency
66
142
 
67
143
  ---
68
144
 
69
145
  ## Real-time streaming pattern
70
146
 
71
- Chat, live dashboards, notifications, LLM token streaming, multiplayer.
147
+ ```
148
+ Client ←→ API Gateway WebSocket ←→ Lambda → DynamoDB (connections)
149
+ → Bedrock (LLM responses)
150
+ ```
151
+
152
+ Or for LLM token streaming:
153
+
154
+ ```
155
+ Client → Lambda Function URL (streaming) → Bedrock ConverseStream
156
+ ```
157
+
158
+ **When:** Chat apps, live dashboards, notifications, LLM token streaming, multiplayer games.
159
+
160
+ **Service selection:**
72
161
 
73
162
  | Decision | Default | Alternative |
74
163
  |---|---|---|
75
164
  | Bidirectional | API Gateway WebSocket | AppSync subscriptions (GraphQL) |
76
165
  | LLM streaming | Lambda Function URL + ConverseStream | REST API proxy with STREAM mode |
77
- | Connection state | DynamoDB (connectionId → metadata, TTL to clean up after 2h max) | ElastiCache (higher throughput) |
78
- | Auth | `$connect` route authorizer | Cognito + custom auth in Lambda |
166
+ | Connection state | DynamoDB (connectionId → metadata, enable TTL to clean up stale connections after 2-hour max duration) | ElastiCache (higher throughput) |
167
+ | Auth | $connect route authorizer | Cognito + custom auth in Lambda |
79
168
 
80
- Constraints: WebSocket 10-min idle / 2-hour max / 128 KB message; Function URL streaming 200 MB, 2 MBps after first 6 MB, Node.js native. **For streaming behind CloudFront, Function URLs should use `AWS_IAM` auth** — use Origin Access Control to sign requests rather than setting auth to `NONE`; if `NONE` is unavoidable, enforce auth at the edge (CloudFront + Lambda@Edge). (For a deliberately public, browser-reachable URL with no edge in front, `NONE` is the intended auth type — see [Function URLs in lambda.md](lambda.md#function-urls) for the required permissions.)
169
+ **Key constraints:**
170
+
171
+ - WebSocket: 10 min idle timeout, 2 hour max connection, 128 KB message (hard limit)
172
+ - Function URL streaming: 200 MB limit, 2 MBps after first 6 MB, Node.js native support
173
+ - Function URLs **MUST** use `AWS_IAM` auth type. For CloudFront integration, use Origin Access Control (OAC) to sign requests — do not set auth to `NONE`. If `NONE` is unavoidable for other reasons, authentication **MUST** be enforced at the edge (e.g., CloudFront + Lambda@Edge). No native JWT/Cognito support.
81
174
 
82
175
  ---
83
176
 
84
177
  ## Async fan-out pattern
85
178
 
86
- One event → multiple independent actions; event-driven microservices.
179
+ ```
180
+ Producer → EventBridge → Rule A → Lambda (process)
181
+ → Rule B → Step Functions (workflow)
182
+ → Rule C → SQS → Lambda (batch)
183
+ ```
184
+
185
+ **When:** One event triggers multiple independent actions, event-driven microservices, cross-service communication.
186
+
187
+ **Service selection:**
87
188
 
88
189
  | Decision | Default | Alternative |
89
190
  |---|---|---|
90
191
  | Event router | EventBridge (content-based routing) | SNS (simpler fan-out, attribute/body filtering) |
91
- | Point-to-point | EventBridge Pipes (no Lambda glue) | SQS → Lambda ESM |
92
- | Schema management | EventBridge Schema Registry + Discovery | Manual docs |
192
+ | Point-to-point | EventBridge Pipes (source→target, no Lambda intermediary) | SQS → Lambda ESM |
193
+ | Schema management | EventBridge Schema Registry + Discovery | Manual schema documentation |
93
194
  | Cross-account | EventBridge cross-account rules | SNS cross-account subscriptions |
94
- | Scheduling | EventBridge Scheduler (cron/rate) | EventBridge rules with schedule expression |
195
+ | Scheduling | EventBridge Scheduler (cron/rate) | EventBridge rules (simpler but less flexible) |
196
+
197
+ **Key constraints:**
95
198
 
96
- Constraints: dedicated event bus per domain (not the default bus); be precise with patterns (broad patterns risk loops); DLQs on all targets.
199
+ - Use dedicated event bus per application domain (not the default bus)
200
+ - EventBridge Pipes eliminates Lambda intermediary functions for source→target integrations
201
+ - Be precise with event patterns — overly broad patterns risk loops
202
+ - Configure DLQs on all targets
97
203
 
98
204
  ---
99
205
 
100
206
  ## Scheduled jobs pattern
101
207
 
102
- Cron jobs, periodic sync, report generation, cleanup.
208
+ ```
209
+ EventBridge Scheduler → Lambda (task)
210
+ → Step Functions (complex workflow)
211
+ ```
212
+
213
+ **When:** Cron jobs, periodic data sync, report generation, cleanup tasks.
214
+
215
+ **Service selection:**
103
216
 
104
217
  | Decision | Default | Alternative |
105
218
  |---|---|---|
106
- | Scheduler | EventBridge Scheduler (flexible, one-time + recurring) | EventBridge rules schedule expression (simpler) |
107
- | Short task (< 15 min) | Lambda directly | — |
108
- | Long task (> 15 min) | Step Functions ( 1 year) | Lambda durable functions |
109
- | High frequency (< 1 min) | Not supported natively | SQS delay queue + Lambda |
219
+ | Scheduler | EventBridge Scheduler (flexible, one-time + recurring) | EventBridge rules with schedule expression (simpler) |
220
+ | Short task (<15 min) | Lambda directly | — |
221
+ | Long task (>15 min) | Step Functions (up to 1 year) | Lambda durable functions |
222
+ | High frequency (<1 min) | Not supported natively | SQS delay queue + Lambda |
110
223
 
111
- Constraints: minimum interval 1 minute; always make scheduled Lambdas idempotent (at-least-once); prefer EventBridge Scheduler over rules for new projects (flexible time windows).
224
+ **Key constraints:**
225
+
226
+ - Minimum schedule interval: 1 minute
227
+ - Lambda max timeout: 15 minutes — use Step Functions for longer
228
+ - Always make scheduled Lambda idempotent (scheduler guarantees at-least-once)
229
+ - Use EventBridge Scheduler over EventBridge rules for new projects (more features, flexible time windows)
112
230
 
113
231
  ---
114
232
 
115
- ## Common combinations
233
+ ## Choosing between patterns
234
+
235
+ Most real applications combine multiple patterns:
116
236
 
117
- | Application | Patterns |
237
+ ```
238
+ ┌─ HTTP API ─── Lambda ─── DynamoDB
239
+ Client ─── CloudFront ─┤
240
+ └─ WebSocket ── Lambda ─── DynamoDB
241
+
242
+
243
+ EventBridge
244
+ ┌────┼────┐
245
+ ▼ ▼ ▼
246
+ SQS SFN Lambda
247
+ │ │
248
+ ▼ ▼
249
+ Lambda Bedrock
250
+ ```
251
+
252
+ **Common combinations:**
253
+
254
+ | Application | Patterns used |
118
255
  |---|---|
119
256
  | SaaS API backend | REST API + Event processing + Scheduled jobs |
120
257
  | E-commerce | REST API + Orchestration (order saga) + Fan-out (notifications) |
121
258
  | Data pipeline | Scheduled jobs + Event processing + Orchestration |
122
259
  | AI chatbot | Real-time streaming + Orchestration (agent loop) |
123
260
  | IoT processing | Event processing + Fan-out + Scheduled jobs (aggregation) |
261
+
262
+ **Begin with a single pattern and add more as requirements grow.** A CRUD API with DynamoDB covers most initial implementations. Add event processing when you need async work. Add orchestration when you need multi-step workflows. Add fan-out when you need cross-service communication.
@@ -1,86 +1,200 @@
1
1
  # Lambda Concurrency Controls
2
2
 
3
- Four concurrency controls operate at different levels with non-obvious interactions. The exact numbers and mutual-exclusivity rules below are the part that's easy to get wrong.
3
+ Four concurrency controls operate at different levels, solve different problems, and have complex interactions.
4
+
5
+ ## Contents
6
+
7
+ - [The 4 concurrency types](#the-4-concurrency-types)
8
+ - [Interaction matrix](#interaction-matrix)
9
+ - [Decision scenarios](#decision-scenarios)
10
+ - [Account limits and scaling](#account-limits-and-scaling)
11
+ - [Common mistakes](#common-mistakes)
12
+ - [SnapStart interaction](#snapstart-interaction)
13
+ - [SAM/CDK examples](#samcdk-property-reference)
14
+
15
+ ---
4
16
 
5
17
  ## The 4 concurrency types
6
18
 
7
- 1. **Reserved Concurrency** (scope: function) — sets the **max** concurrent instances AND reserves that capacity from the account pool. Setting to **0** fully throttles the function (emergency shutoff). Use to protect critical functions, cap to protect downstream, or kill-switch.
19
+ ### 1. Reserved Concurrency
20
+ Sets the **maximum** concurrent instances for a function and **reserves** that capacity from the account pool so no other function can consume it.
21
+
22
+ - **Scope:** Function.
23
+ - Reserve 400 → function always gets up to 400, never more. Others share the rest.
24
+ - Setting to **0** completely throttles the function (emergency shutoff).
25
+ - Use for: protecting critical functions, capping to protect downstream, emergency shutoff.
26
+
27
+ ### 2. Provisioned Concurrency
28
+ Pre-initializes execution environments so they are **ready before requests arrive**.
8
29
 
9
- 2. **Provisioned Concurrency** (scope: published version or alias **NOT `$LATEST`**) — pre-initializes environments so they're ready before requests arrive. Spills to on-demand (with cold starts) beyond the provisioned count. Combine with Application Auto Scaling (~70% target). Paid even when idle.
30
+ - **Scope:** Published version or alias (**NOT** `$LATEST`).
31
+ - **Allocation rate:** Up to 6,000 environments per minute when provisioning.
32
+ - Configure 100 on alias `PROD` → first 100 concurrent requests get sub-10ms startup.
33
+ Request 101+ spills to on-demand with cold starts.
34
+ - **Account-level RPS quota**: RPS = 10 × account concurrency. For example, 1,000 account concurrency → 10,000 RPS cap across all functions. This is an account-level quota, not a per-instance throughput cap. Per-instance throughput = 1 / function duration.
35
+ - Combine with **Application Auto Scaling** (target ~70% utilization).
36
+ - Use for: user-facing APIs, functions with heavy init (ML models, DB pools).
10
37
 
11
- 3. **Maximum Concurrency** (scope: per SQS ESM, range **2–1,000**) — caps how many concurrent instances one SQS ESM can invoke. Does **not** reserve anything; other triggers can still consume function concurrency.
38
+ ### 3. Maximum Concurrency
39
+ Limits how many concurrent instances a **specific SQS event source mapping (ESM)** can invoke.
12
40
 
13
- 4. **Provisioned Mode ESM** (SQS and Kafka/MSK) — allocates dedicated event pollers for an SQS/Kafka ESM with configurable min/max. Per-poller capacity is an **OR** envelope and differs by source: **SQS = 1 MB/s or 10 concurrent invokes**; **Kafka/MSK = 5 MB/s or 5 concurrent invokes**. Use for high-throughput or spiky traffic where standard ramp-up (5 → +300/min) is too slow.
41
+ - **Scope:** Per ESM. **Range:** 2–1,000. **Sources:** SQS only.
42
+ - Does **not** reserve anything — other triggers can still consume function concurrency.
43
+ - Use for: multiple SQS queues on one function, rate-limiting a specific queue.
14
44
 
15
- ## Key numbers and interactions
45
+ ### 4. Provisioned Mode — ESM (Kafka 2024, SQS 2025)
46
+ Allocates **dedicated event pollers** for an SQS or Kafka ESM with configurable min/max.
16
47
 
17
- - **Account RPS quota = 10 × account concurrency** (e.g. 1,000 concurrency → 10,000 RPS, across all functions). This is an account quota, not a per-instance cap. Per-instance throughput = 1 / function duration.
18
- - **Max reservable = account limit 100.** Lambda always keeps 100 unreserved.
19
- - **Scaling rate: 1,000 new environments / 10s, per function**
20
- - Provisioned Reserved when both are set (reserved is the ceiling).
21
- - Provisioned counts against the account limit even when idle — monitor `ClaimedAccountConcurrency`.
48
+ - **Scope:** Per ESM.
49
+ - Standard mode: ~5 pollers, +300/min, max 1,250 invokes. Provisioned mode: you control
50
+ min/max pollers. Each handles up to 1 MB/s, 10 concurrent invokes.
51
+ - Use for: high-throughput SQS/Kafka, spiky traffic where standard ramp-up is too slow.
52
+
53
+ ---
54
+
55
+ ## Interaction matrix
22
56
 
23
57
  | Combination | OK? | Notes |
24
58
  |-------------|:---:|-------|
25
59
  | Reserved + Provisioned | Yes | Provisioned ≤ Reserved |
26
- | Reserved + Maximum Concurrency (ESM) | Yes | Reserved ≥ Σ(Maximum Concurrency across ESMs) |
27
- | Provisioned + Maximum Concurrency / Provisioned Mode (ESM) | Yes | Different layers |
28
- | **Maximum Concurrency + Provisioned Mode (same ESM)** | **No** | **Mutually exclusive** |
29
- | **Provisioned Concurrency + SnapStart** | **No** | **Mutually exclusive** |
30
-
31
- **At the limit:** Sync 429. Async retries up to 6h then DLQ. Streams → polling throttled, messages stay in source.
60
+ | Reserved + Max Concurrency (ESM) | Yes | Reserved ≥ Σ(max concurrency across ESMs) |
61
+ | Reserved + Provisioned Mode (ESM) | Yes | Independent layers |
62
+ | Provisioned + Max Concurrency (ESM) | Yes | Different layers |
63
+ | Provisioned + Provisioned Mode (ESM) | Yes | Warms envs vs warms pollers |
64
+ | **Max Concurrency + Provisioned Mode (same ESM)** | No | **Mutually exclusive** |
65
+ | **Provisioned Concurrency + SnapStart** | No | **Mutually exclusive** |
32
66
 
33
- **RPS gotcha:** a 50ms function at 20,000 RPS needs only 1,000 concurrency, but the RPS limit (10×1,000 = 10,000) throttles it. Request account concurrency = 2,000.
67
+ **Key rules:** Account limit is the hard ceiling. Reserved carves from the pool Lambda
68
+ always keeps **100 unreserved**. Provisioned ≤ Reserved when both set. Max Concurrency is
69
+ advisory to the ESM, not the function.
34
70
 
35
- ```bash
36
- aws service-quotas request-service-quota-increase \
37
- --service-code lambda --quota-code L-B99A9384 --desired-value 5000
38
71
  ```
72
+ ┌──────────────────────────────────────────────────────┐
73
+ │ ACCOUNT: 1,000 concurrency │
74
+ │ ┌─────────────────┐ ┌───────────────────────────┐ │
75
+ │ │ RESERVED (400) │ │ UNRESERVED POOL (600) │ │
76
+ │ │ ┌─────────────┐ │ │ Shared by all others │ │
77
+ │ │ │PROVISIONED │ │ │ Must keep ≥100 always │ │
78
+ │ │ │(200 warm) │ │ └───────────────────────────┘ │
79
+ │ │ └─────────────┘ │ │
80
+ │ │ + 200 on-demand │ ESM LAYER (per mapping): │
81
+ │ └─────────────────┘ Max Concurrency — OR — │
82
+ │ Provisioned Mode (not both) │
83
+ └──────────────────────────────────────────────────────┘
84
+ ```
85
+
86
+ ---
39
87
 
40
88
  ## Decision scenarios
41
89
 
42
- | Scenario | Reserved | Provisioned | Maximum Concurrency (ESM) | Prov Mode (ESM) |
90
+ | Scenario | Reserved | Provisioned | Max Conc (ESM) | Prov Mode (ESM) |
43
91
  |----------|:--------:|:-----------:|:--------------:|:---------------:|
44
- | Protect critical API / cap downstream | Yes | — | — | — |
45
- | Eliminate cold starts (user-facing API) | Optional | Yes | — | — |
92
+ | Protect critical API from starvation | Yes | — | — | — |
93
+ | Cap function to protect downstream DB | Yes | | — | — |
94
+ | Eliminate cold starts for user-facing API | Optional | Yes | — | — |
46
95
  | Multiple SQS queues, prevent hogging | Yes | — | Yes | — |
47
96
  | High-throughput SQS, low-latency | Optional | Optional | — | Yes |
48
- | Kafka/SQS ESM with spiky traffic | — | — | — | Yes |
49
- | Predictable daily traffic | — | Yes + AutoScale | — | — |
97
+ | Kafka ESM with spiky traffic | — | — | — | Yes |
98
+ | Predictable daily traffic | — | Yes+AutoScale | — | — |
50
99
  | Emergency shutoff | Yes (=0) | — | — | — |
100
+ | Java/.NET heavy init | — | Yes or SnapStart | — | — |
101
+
102
+ **A — Checkout API:** Reserved=200 + Provisioned=150 + Auto Scaling for peak.
103
+ **B — 3 SQS queues → 1 function:** Reserved=300, Max Concurrency=100 per ESM.
104
+ **C — Kafka stream (spiky):** Provisioned Mode min=5, max=50 pollers.
105
+ **D — Batch job:** Reserved=50, no provisioned.
106
+
107
+ ---
108
+
109
+ ## Account limits and scaling
110
+
111
+ | Quota | Default | Adjustable? |
112
+ |-------|---------|:-----------:|
113
+ | Account concurrency | 1,000 / Region | Yes |
114
+ | Reservable concurrency | Account − 100 | Scales |
115
+ | RPS limit | 10 × concurrency | Scales |
116
+ | Scaling rate | 1,000 envs / 10s / function | No |
117
+
118
+ Scaling is per-function, continuously refilled, unused capacity does not accumulate.
119
+ ~50 seconds to reach 5,000 concurrency from zero.
120
+
121
+ **At the limit:** Sync → 429. Async → retries up to 6h then DLQ. Streams → polling
122
+ throttled, messages stay in source.
123
+
124
+ **RPS constraint:** A 50ms function at 20,000 RPS needs only 1,000 concurrency but the RPS
125
+ limit (10×1,000=10,000) throttles it. Request account concurrency = 2,000.
126
+
127
+ ```bash
128
+ aws service-quotas request-service-quota-increase \
129
+ --service-code lambda --quota-code L-B99A9384 --desired-value 5000
130
+ ```
131
+
132
+ ---
51
133
 
52
134
  ## Common mistakes
53
135
 
54
- 1. **Reserved = 0 left over from an incident** — blocks ALL invocations (429). If a function throttles at low traffic, check this first.
55
- 2. **Reserved too low** reserve 50, need 80 throttled at 51 even with spare account capacity.
56
- 3. **Starving other functions** — reserved is subtracted even when unused; be conservative.
57
- 4. **Provisioned without auto scaling** — paying for idle off-peak, spilling on-peak.
58
- 5. **Provisioned on `$LATEST`**doesn't work; publish a version, create an alias.
59
- 6. **Maximum Concurrency > reserved** ESM tries 100, function caps at 50. Ensure reserved ≥ Σ(Maximum Concurrency).
60
- 7. **Confusing ESM Maximum Concurrency with reserved** — Maximum Concurrency reserves nothing; API Gateway can still consume all concurrency.
61
- 8. **Forgetting the 100-unit buffer** — max reservable = account limit 100.
136
+ 1. **Reserved set to 0** — Blocks ALL invocations (429 TooManyRequestsException). Sometimes
137
+ set during an incident and not restored. If a function is throttled at low traffic, check
138
+ this first.
139
+
140
+ 2. **Reserved too low**Reserve 50, need 80 throttled at 51 even with spare account
141
+ capacity. Fix: monitor `ConcurrentExecutions`, set above peak + buffer.
142
+
143
+ 3. **Starving other functions** — Reserve 800/1,000 others share 200. Reserved is
144
+ subtracted even when unused. Fix: be conservative.
145
+
146
+ 4. **Provisioned without auto scaling** — Paying for idle envs off-peak, spilling on-peak.
147
+ Fix: Auto Scaling targeting ~70% `ProvisionedConcurrencyUtilization`.
148
+
149
+ 5. **Provisioned on `$LATEST`** — Doesn't work. Fix: publish a version, create an alias.
62
150
 
63
- ## SnapStart vs Provisioned Concurrency
151
+ 6. **Max concurrency > reserved** — ESM tries 100, function caps at 50. Fix: ensure
152
+ `reserved ≥ Σ(max concurrency across ESMs)`.
64
153
 
65
- > **Mutually exclusive on the same function.**
154
+ 7. **Confusing ESM max with reserved** — Max concurrency doesn't reserve anything. API
155
+ Gateway can still consume all concurrency. Fix: use reserved on the function.
156
+
157
+ 8. **Both ESM controls on same ESM** — Mutually exclusive; API rejects it. Fix: choose one.
158
+
159
+ 9. **Forgetting 100-unit buffer** — Max reservable = account limit − 100.
160
+
161
+ 10. **Not tracking ClaimedAccountConcurrency** — Provisioned counts against account limit
162
+ even when idle. Monitor the metric.
163
+
164
+ ---
165
+
166
+ ## SnapStart interaction
167
+
168
+ | Aspect | SnapStart | Provisioned Concurrency |
169
+ |--------|-----------|------------------------|
170
+ | Cold start | Seconds → sub-second | Seconds → ~0 |
171
+ | Runtimes | Java 11+, Python 3.12+, .NET 8+ | All |
172
+ | Scales with traffic | Yes (snapshot restore) | Only up to provisioned count |
173
+
174
+ > **SnapStart and Provisioned Concurrency are mutually exclusive on the same function.**
66
175
 
67
176
  ```
68
- Runtime Java 11+ / Python 3.12+ / .NET 8+
177
+ Is runtime Java 11+, Python 3.12+, or .NET 8+?
69
178
  ├─ No → Provisioned Concurrency
70
179
  └─ Yes
71
180
  ├─ Need guaranteed <50ms on EVERY request? → Provisioned Concurrency
72
181
  ├─ Need EFS or >512MB ephemeral storage? → Provisioned Concurrency
73
- └─ Otherwise → SnapStart first; if P99 still too high, switch (they cannot coexist)
182
+ └─ Otherwise → SnapStart first; if P99 still too high, switch to Provisioned Concurrency (they cannot coexist)
74
183
  ```
75
184
 
185
+ Limitations: no EFS, no >512MB ephemeral, no container images, must handle uniqueness,
186
+ re-validate network connections on restore.
187
+
188
+ ---
189
+
76
190
  ## SAM/CDK property reference
77
191
 
78
- | Type | SAM | CDK |
192
+ | Concurrency type | SAM property | CDK property |
79
193
  |---|---|---|
80
- | Reserved | `ReservedConcurrentExecutions` | `reservedConcurrentExecutions` |
81
- | Provisioned | `AutoPublishAlias` + `ProvisionedConcurrencyConfig.ProvisionedConcurrentExecutions` | `new lambda.Alias({ provisionedConcurrentExecutions })` (alias, not `$LATEST`) |
82
- | Maximum Concurrency (ESM) | `ScalingConfig.MaximumConcurrency` | `maxConcurrency` on `EventSourceMapping` |
83
- | Provisioned Mode (ESM) | `ProvisionedPollerConfig.MinimumPollers` / `MaximumPollers` | `provisionedPollerConfig: { minimumPollers, maximumPollers }` |
194
+ | Reserved | `ReservedConcurrentExecutions: 100` | `reservedConcurrentExecutions: 100` |
195
+ | Provisioned | `AutoPublishAlias: live` + `ProvisionedConcurrencyConfig.ProvisionedConcurrentExecutions: 50` | `new lambda.Alias({ provisionedConcurrentExecutions: 50 })` — must use alias, not `$LATEST` |
196
+ | Maximum Concurrency (ESM) | `ScalingConfig.MaximumConcurrency: 50` | `maxConcurrency: 50` on `EventSourceMapping` |
197
+ | Provisioned Mode (ESM) | `ProvisionedPollerConfig.MinimumPollers` / `MaximumPollers` | `provisionedPollerConfig: { minimumPollers, maximumPollers }` on `EventSourceMapping` |
84
198
  | SnapStart | `SnapStart.ApplyOn: PublishedVersions` + `AutoPublishAlias` | `snapStart: lambda.SnapStartConf.ON_PUBLISHED_VERSIONS` |
85
199
 
86
- Auto scaling: `alias.addAutoScaling({ minCapacity, maxCapacity })` then `scaling.scaleOnUtilization({ utilizationTarget: 0.7 })`.
200
+ Auto scaling for Provisioned Concurrency: `alias.addAutoScaling({ minCapacity, maxCapacity })` then `scaling.scaleOnUtilization({ utilizationTarget: 0.7 })`.
@@ -1,6 +1,6 @@
1
1
  # Deployment Reference
2
2
 
3
- Serverless-specific resource types and fast-iteration tools. For step-by-step deployment procedures (custom domain REST API, API Gateway stages, connecting Lambda to API Gateway/DynamoDB), use the specialized skills in SKILL.md's routing table.
3
+ Serverless-specific deployment patterns, resource types, and fast iteration tools.
4
4
 
5
5
  ## Contents
6
6