@wazir-dev/cli 1.0.0
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/AGENTS.md +111 -0
- package/CHANGELOG.md +14 -0
- package/CONTRIBUTING.md +101 -0
- package/LICENSE +21 -0
- package/README.md +314 -0
- package/assets/composition-engine.mmd +34 -0
- package/assets/demo-script.sh +17 -0
- package/assets/logo-dark.svg +14 -0
- package/assets/logo.svg +14 -0
- package/assets/pipeline.mmd +39 -0
- package/assets/record-demo.sh +51 -0
- package/docs/README.md +51 -0
- package/docs/adapters/context-mode.md +60 -0
- package/docs/concepts/architecture.md +87 -0
- package/docs/concepts/artifact-model.md +60 -0
- package/docs/concepts/composition-engine.md +36 -0
- package/docs/concepts/indexing-and-recall.md +160 -0
- package/docs/concepts/observability.md +41 -0
- package/docs/concepts/roles-and-workflows.md +59 -0
- package/docs/concepts/terminology-policy.md +27 -0
- package/docs/getting-started/01-installation.md +78 -0
- package/docs/getting-started/02-first-run.md +102 -0
- package/docs/getting-started/03-adding-to-project.md +15 -0
- package/docs/getting-started/04-host-setup.md +15 -0
- package/docs/guides/ci-integration.md +15 -0
- package/docs/guides/creating-skills.md +15 -0
- package/docs/guides/expertise-module-authoring.md +15 -0
- package/docs/guides/hook-development.md +15 -0
- package/docs/guides/memory-and-learnings.md +34 -0
- package/docs/guides/multi-host-export.md +15 -0
- package/docs/guides/troubleshooting.md +101 -0
- package/docs/guides/writing-custom-roles.md +15 -0
- package/docs/plans/2026-03-15-cli-pipeline-integration-design.md +592 -0
- package/docs/plans/2026-03-15-cli-pipeline-integration-plan.md +598 -0
- package/docs/plans/2026-03-15-docs-enforcement-plan.md +238 -0
- package/docs/readmes/INDEX.md +99 -0
- package/docs/readmes/features/expertise/README.md +171 -0
- package/docs/readmes/features/exports/README.md +222 -0
- package/docs/readmes/features/hooks/README.md +103 -0
- package/docs/readmes/features/hooks/loop-cap-guard.md +133 -0
- package/docs/readmes/features/hooks/post-tool-capture.md +121 -0
- package/docs/readmes/features/hooks/post-tool-lint.md +130 -0
- package/docs/readmes/features/hooks/pre-compact-summary.md +122 -0
- package/docs/readmes/features/hooks/pre-tool-capture-route.md +100 -0
- package/docs/readmes/features/hooks/protected-path-write-guard.md +128 -0
- package/docs/readmes/features/hooks/session-start.md +119 -0
- package/docs/readmes/features/hooks/stop-handoff-harvest.md +125 -0
- package/docs/readmes/features/roles/README.md +157 -0
- package/docs/readmes/features/roles/clarifier.md +152 -0
- package/docs/readmes/features/roles/content-author.md +190 -0
- package/docs/readmes/features/roles/designer.md +193 -0
- package/docs/readmes/features/roles/executor.md +184 -0
- package/docs/readmes/features/roles/learner.md +210 -0
- package/docs/readmes/features/roles/planner.md +182 -0
- package/docs/readmes/features/roles/researcher.md +164 -0
- package/docs/readmes/features/roles/reviewer.md +184 -0
- package/docs/readmes/features/roles/specifier.md +162 -0
- package/docs/readmes/features/roles/verifier.md +215 -0
- package/docs/readmes/features/schemas/README.md +178 -0
- package/docs/readmes/features/skills/README.md +63 -0
- package/docs/readmes/features/skills/brainstorming.md +96 -0
- package/docs/readmes/features/skills/debugging.md +148 -0
- package/docs/readmes/features/skills/design.md +120 -0
- package/docs/readmes/features/skills/prepare-next.md +109 -0
- package/docs/readmes/features/skills/run-audit.md +159 -0
- package/docs/readmes/features/skills/scan-project.md +109 -0
- package/docs/readmes/features/skills/self-audit.md +176 -0
- package/docs/readmes/features/skills/tdd.md +137 -0
- package/docs/readmes/features/skills/using-skills.md +92 -0
- package/docs/readmes/features/skills/verification.md +120 -0
- package/docs/readmes/features/skills/writing-plans.md +104 -0
- package/docs/readmes/features/tooling/README.md +320 -0
- package/docs/readmes/features/workflows/README.md +186 -0
- package/docs/readmes/features/workflows/author.md +181 -0
- package/docs/readmes/features/workflows/clarify.md +154 -0
- package/docs/readmes/features/workflows/design-review.md +171 -0
- package/docs/readmes/features/workflows/design.md +169 -0
- package/docs/readmes/features/workflows/discover.md +162 -0
- package/docs/readmes/features/workflows/execute.md +173 -0
- package/docs/readmes/features/workflows/learn.md +167 -0
- package/docs/readmes/features/workflows/plan-review.md +165 -0
- package/docs/readmes/features/workflows/plan.md +170 -0
- package/docs/readmes/features/workflows/prepare-next.md +167 -0
- package/docs/readmes/features/workflows/review.md +169 -0
- package/docs/readmes/features/workflows/run-audit.md +191 -0
- package/docs/readmes/features/workflows/spec-challenge.md +159 -0
- package/docs/readmes/features/workflows/specify.md +160 -0
- package/docs/readmes/features/workflows/verify.md +177 -0
- package/docs/readmes/packages/README.md +50 -0
- package/docs/readmes/packages/ajv.md +117 -0
- package/docs/readmes/packages/context-mode.md +118 -0
- package/docs/readmes/packages/gray-matter.md +116 -0
- package/docs/readmes/packages/node-test.md +137 -0
- package/docs/readmes/packages/yaml.md +112 -0
- package/docs/reference/configuration-reference.md +159 -0
- package/docs/reference/expertise-index.md +52 -0
- package/docs/reference/git-flow.md +43 -0
- package/docs/reference/hooks.md +87 -0
- package/docs/reference/host-exports.md +50 -0
- package/docs/reference/launch-checklist.md +172 -0
- package/docs/reference/marketplace-listings.md +76 -0
- package/docs/reference/release-process.md +34 -0
- package/docs/reference/roles-reference.md +77 -0
- package/docs/reference/skills.md +33 -0
- package/docs/reference/templates.md +29 -0
- package/docs/reference/tooling-cli.md +94 -0
- package/docs/truth-claims.yaml +222 -0
- package/expertise/PROGRESS.md +63 -0
- package/expertise/README.md +18 -0
- package/expertise/antipatterns/PROGRESS.md +56 -0
- package/expertise/antipatterns/backend/api-design-antipatterns.md +1271 -0
- package/expertise/antipatterns/backend/auth-antipatterns.md +1195 -0
- package/expertise/antipatterns/backend/caching-antipatterns.md +622 -0
- package/expertise/antipatterns/backend/database-antipatterns.md +1038 -0
- package/expertise/antipatterns/backend/index.md +24 -0
- package/expertise/antipatterns/backend/microservices-antipatterns.md +850 -0
- package/expertise/antipatterns/code/architecture-antipatterns.md +919 -0
- package/expertise/antipatterns/code/async-antipatterns.md +622 -0
- package/expertise/antipatterns/code/code-smells.md +1186 -0
- package/expertise/antipatterns/code/dependency-antipatterns.md +1209 -0
- package/expertise/antipatterns/code/error-handling-antipatterns.md +1360 -0
- package/expertise/antipatterns/code/index.md +27 -0
- package/expertise/antipatterns/code/naming-and-abstraction.md +1118 -0
- package/expertise/antipatterns/code/state-management-antipatterns.md +1076 -0
- package/expertise/antipatterns/code/testing-antipatterns.md +1053 -0
- package/expertise/antipatterns/design/accessibility-antipatterns.md +1136 -0
- package/expertise/antipatterns/design/dark-patterns.md +1121 -0
- package/expertise/antipatterns/design/index.md +22 -0
- package/expertise/antipatterns/design/ui-antipatterns.md +1202 -0
- package/expertise/antipatterns/design/ux-antipatterns.md +680 -0
- package/expertise/antipatterns/frontend/css-layout-antipatterns.md +691 -0
- package/expertise/antipatterns/frontend/flutter-antipatterns.md +1827 -0
- package/expertise/antipatterns/frontend/index.md +23 -0
- package/expertise/antipatterns/frontend/mobile-antipatterns.md +573 -0
- package/expertise/antipatterns/frontend/react-antipatterns.md +1128 -0
- package/expertise/antipatterns/frontend/spa-antipatterns.md +1235 -0
- package/expertise/antipatterns/index.md +31 -0
- package/expertise/antipatterns/performance/index.md +20 -0
- package/expertise/antipatterns/performance/performance-antipatterns.md +1013 -0
- package/expertise/antipatterns/performance/premature-optimization.md +623 -0
- package/expertise/antipatterns/performance/scaling-antipatterns.md +785 -0
- package/expertise/antipatterns/process/ai-coding-antipatterns.md +853 -0
- package/expertise/antipatterns/process/code-review-antipatterns.md +656 -0
- package/expertise/antipatterns/process/deployment-antipatterns.md +920 -0
- package/expertise/antipatterns/process/index.md +23 -0
- package/expertise/antipatterns/process/technical-debt-antipatterns.md +647 -0
- package/expertise/antipatterns/security/index.md +20 -0
- package/expertise/antipatterns/security/secrets-antipatterns.md +849 -0
- package/expertise/antipatterns/security/security-theater.md +843 -0
- package/expertise/antipatterns/security/vulnerability-patterns.md +801 -0
- package/expertise/architecture/PROGRESS.md +70 -0
- package/expertise/architecture/data/caching-architecture.md +671 -0
- package/expertise/architecture/data/data-consistency.md +574 -0
- package/expertise/architecture/data/data-modeling.md +536 -0
- package/expertise/architecture/data/event-streams-and-queues.md +634 -0
- package/expertise/architecture/data/index.md +25 -0
- package/expertise/architecture/data/search-architecture.md +663 -0
- package/expertise/architecture/data/sql-vs-nosql.md +708 -0
- package/expertise/architecture/decisions/architecture-decision-records.md +640 -0
- package/expertise/architecture/decisions/build-vs-buy.md +616 -0
- package/expertise/architecture/decisions/index.md +23 -0
- package/expertise/architecture/decisions/monolith-to-microservices.md +790 -0
- package/expertise/architecture/decisions/technology-selection.md +616 -0
- package/expertise/architecture/distributed/cap-theorem-and-tradeoffs.md +800 -0
- package/expertise/architecture/distributed/circuit-breaker-bulkhead.md +741 -0
- package/expertise/architecture/distributed/consensus-and-coordination.md +796 -0
- package/expertise/architecture/distributed/distributed-systems-fundamentals.md +564 -0
- package/expertise/architecture/distributed/idempotency-and-retry.md +796 -0
- package/expertise/architecture/distributed/index.md +25 -0
- package/expertise/architecture/distributed/saga-pattern.md +797 -0
- package/expertise/architecture/foundations/architectural-thinking.md +460 -0
- package/expertise/architecture/foundations/coupling-and-cohesion.md +770 -0
- package/expertise/architecture/foundations/design-principles-solid.md +649 -0
- package/expertise/architecture/foundations/domain-driven-design.md +719 -0
- package/expertise/architecture/foundations/index.md +25 -0
- package/expertise/architecture/foundations/separation-of-concerns.md +472 -0
- package/expertise/architecture/foundations/twelve-factor-app.md +797 -0
- package/expertise/architecture/index.md +34 -0
- package/expertise/architecture/integration/api-design-graphql.md +638 -0
- package/expertise/architecture/integration/api-design-grpc.md +804 -0
- package/expertise/architecture/integration/api-design-rest.md +892 -0
- package/expertise/architecture/integration/index.md +25 -0
- package/expertise/architecture/integration/third-party-integration.md +795 -0
- package/expertise/architecture/integration/webhooks-and-callbacks.md +1152 -0
- package/expertise/architecture/integration/websockets-realtime.md +791 -0
- package/expertise/architecture/mobile-architecture/index.md +22 -0
- package/expertise/architecture/mobile-architecture/mobile-app-architecture.md +780 -0
- package/expertise/architecture/mobile-architecture/mobile-backend-for-frontend.md +670 -0
- package/expertise/architecture/mobile-architecture/offline-first.md +719 -0
- package/expertise/architecture/mobile-architecture/push-and-sync.md +782 -0
- package/expertise/architecture/patterns/cqrs-event-sourcing.md +717 -0
- package/expertise/architecture/patterns/event-driven.md +797 -0
- package/expertise/architecture/patterns/hexagonal-clean-architecture.md +870 -0
- package/expertise/architecture/patterns/index.md +27 -0
- package/expertise/architecture/patterns/layered-architecture.md +736 -0
- package/expertise/architecture/patterns/microservices.md +753 -0
- package/expertise/architecture/patterns/modular-monolith.md +692 -0
- package/expertise/architecture/patterns/monolith.md +626 -0
- package/expertise/architecture/patterns/plugin-architecture.md +735 -0
- package/expertise/architecture/patterns/serverless.md +780 -0
- package/expertise/architecture/scaling/database-scaling.md +615 -0
- package/expertise/architecture/scaling/feature-flags-and-rollouts.md +757 -0
- package/expertise/architecture/scaling/horizontal-vs-vertical.md +606 -0
- package/expertise/architecture/scaling/index.md +24 -0
- package/expertise/architecture/scaling/multi-tenancy.md +800 -0
- package/expertise/architecture/scaling/stateless-design.md +787 -0
- package/expertise/backend/embedded-firmware.md +625 -0
- package/expertise/backend/go.md +853 -0
- package/expertise/backend/index.md +24 -0
- package/expertise/backend/java-spring.md +448 -0
- package/expertise/backend/node-typescript.md +625 -0
- package/expertise/backend/python-fastapi.md +724 -0
- package/expertise/backend/rust.md +458 -0
- package/expertise/backend/solidity.md +711 -0
- package/expertise/composition-map.yaml +443 -0
- package/expertise/content/foundations/content-modeling.md +395 -0
- package/expertise/content/foundations/editorial-standards.md +449 -0
- package/expertise/content/foundations/index.md +24 -0
- package/expertise/content/foundations/microcopy.md +455 -0
- package/expertise/content/foundations/terminology-governance.md +509 -0
- package/expertise/content/index.md +34 -0
- package/expertise/content/patterns/accessibility-copy.md +518 -0
- package/expertise/content/patterns/index.md +24 -0
- package/expertise/content/patterns/notification-content.md +433 -0
- package/expertise/content/patterns/sample-content.md +486 -0
- package/expertise/content/patterns/state-copy.md +439 -0
- package/expertise/design/PROGRESS.md +58 -0
- package/expertise/design/disciplines/dark-mode-theming.md +577 -0
- package/expertise/design/disciplines/design-systems.md +595 -0
- package/expertise/design/disciplines/index.md +25 -0
- package/expertise/design/disciplines/information-architecture.md +800 -0
- package/expertise/design/disciplines/interaction-design.md +788 -0
- package/expertise/design/disciplines/responsive-design.md +552 -0
- package/expertise/design/disciplines/usability-testing.md +516 -0
- package/expertise/design/disciplines/user-research.md +792 -0
- package/expertise/design/foundations/accessibility-design.md +796 -0
- package/expertise/design/foundations/color-theory.md +797 -0
- package/expertise/design/foundations/iconography.md +795 -0
- package/expertise/design/foundations/index.md +26 -0
- package/expertise/design/foundations/motion-and-animation.md +653 -0
- package/expertise/design/foundations/rtl-design.md +585 -0
- package/expertise/design/foundations/spacing-and-layout.md +607 -0
- package/expertise/design/foundations/typography.md +800 -0
- package/expertise/design/foundations/visual-hierarchy.md +761 -0
- package/expertise/design/index.md +32 -0
- package/expertise/design/patterns/authentication-flows.md +474 -0
- package/expertise/design/patterns/content-consumption.md +789 -0
- package/expertise/design/patterns/data-display.md +618 -0
- package/expertise/design/patterns/e-commerce.md +1494 -0
- package/expertise/design/patterns/feedback-and-states.md +642 -0
- package/expertise/design/patterns/forms-and-input.md +819 -0
- package/expertise/design/patterns/gamification.md +801 -0
- package/expertise/design/patterns/index.md +31 -0
- package/expertise/design/patterns/microinteractions.md +449 -0
- package/expertise/design/patterns/navigation.md +800 -0
- package/expertise/design/patterns/notifications.md +705 -0
- package/expertise/design/patterns/onboarding.md +700 -0
- package/expertise/design/patterns/search-and-filter.md +601 -0
- package/expertise/design/patterns/settings-and-preferences.md +768 -0
- package/expertise/design/patterns/social-and-community.md +748 -0
- package/expertise/design/platforms/desktop-native.md +612 -0
- package/expertise/design/platforms/index.md +25 -0
- package/expertise/design/platforms/mobile-android.md +825 -0
- package/expertise/design/platforms/mobile-cross-platform.md +983 -0
- package/expertise/design/platforms/mobile-ios.md +699 -0
- package/expertise/design/platforms/tablet.md +794 -0
- package/expertise/design/platforms/web-dashboard.md +790 -0
- package/expertise/design/platforms/web-responsive.md +550 -0
- package/expertise/design/psychology/behavioral-nudges.md +449 -0
- package/expertise/design/psychology/cognitive-load.md +1191 -0
- package/expertise/design/psychology/error-psychology.md +778 -0
- package/expertise/design/psychology/index.md +22 -0
- package/expertise/design/psychology/persuasive-design.md +736 -0
- package/expertise/design/psychology/user-mental-models.md +623 -0
- package/expertise/design/tooling/open-pencil.md +266 -0
- package/expertise/frontend/angular.md +1073 -0
- package/expertise/frontend/desktop-electron.md +546 -0
- package/expertise/frontend/flutter.md +782 -0
- package/expertise/frontend/index.md +27 -0
- package/expertise/frontend/native-android.md +409 -0
- package/expertise/frontend/native-ios.md +490 -0
- package/expertise/frontend/react-native.md +1160 -0
- package/expertise/frontend/react.md +808 -0
- package/expertise/frontend/vue.md +1089 -0
- package/expertise/humanize/domain-rules-code.md +79 -0
- package/expertise/humanize/domain-rules-content.md +67 -0
- package/expertise/humanize/domain-rules-technical-docs.md +56 -0
- package/expertise/humanize/index.md +35 -0
- package/expertise/humanize/self-audit-checklist.md +87 -0
- package/expertise/humanize/sentence-patterns.md +218 -0
- package/expertise/humanize/vocabulary-blacklist.md +105 -0
- package/expertise/i18n/PROGRESS.md +65 -0
- package/expertise/i18n/advanced/accessibility-and-i18n.md +28 -0
- package/expertise/i18n/advanced/bidirectional-text-algorithm.md +38 -0
- package/expertise/i18n/advanced/complex-scripts.md +30 -0
- package/expertise/i18n/advanced/performance-and-i18n.md +27 -0
- package/expertise/i18n/advanced/testing-i18n.md +28 -0
- package/expertise/i18n/content/content-adaptation.md +23 -0
- package/expertise/i18n/content/locale-specific-formatting.md +23 -0
- package/expertise/i18n/content/machine-translation-integration.md +28 -0
- package/expertise/i18n/content/translation-management.md +29 -0
- package/expertise/i18n/foundations/date-time-calendars.md +67 -0
- package/expertise/i18n/foundations/i18n-architecture.md +272 -0
- package/expertise/i18n/foundations/locale-and-language-tags.md +79 -0
- package/expertise/i18n/foundations/numbers-currency-units.md +61 -0
- package/expertise/i18n/foundations/pluralization-and-gender.md +109 -0
- package/expertise/i18n/foundations/string-externalization.md +236 -0
- package/expertise/i18n/foundations/text-direction-bidi.md +241 -0
- package/expertise/i18n/foundations/unicode-and-encoding.md +86 -0
- package/expertise/i18n/index.md +38 -0
- package/expertise/i18n/platform/backend-i18n.md +31 -0
- package/expertise/i18n/platform/flutter-i18n.md +148 -0
- package/expertise/i18n/platform/native-android-i18n.md +36 -0
- package/expertise/i18n/platform/native-ios-i18n.md +36 -0
- package/expertise/i18n/platform/react-i18n.md +103 -0
- package/expertise/i18n/platform/web-css-i18n.md +81 -0
- package/expertise/i18n/rtl/arabic-specific.md +175 -0
- package/expertise/i18n/rtl/hebrew-specific.md +149 -0
- package/expertise/i18n/rtl/rtl-animations-and-transitions.md +111 -0
- package/expertise/i18n/rtl/rtl-forms-and-input.md +161 -0
- package/expertise/i18n/rtl/rtl-fundamentals.md +211 -0
- package/expertise/i18n/rtl/rtl-icons-and-images.md +181 -0
- package/expertise/i18n/rtl/rtl-layout-mirroring.md +252 -0
- package/expertise/i18n/rtl/rtl-navigation-and-gestures.md +107 -0
- package/expertise/i18n/rtl/rtl-testing-and-qa.md +147 -0
- package/expertise/i18n/rtl/rtl-typography.md +160 -0
- package/expertise/index.md +113 -0
- package/expertise/index.yaml +216 -0
- package/expertise/infrastructure/cloud-aws.md +597 -0
- package/expertise/infrastructure/cloud-gcp.md +599 -0
- package/expertise/infrastructure/cybersecurity.md +816 -0
- package/expertise/infrastructure/database-mongodb.md +447 -0
- package/expertise/infrastructure/database-postgres.md +400 -0
- package/expertise/infrastructure/devops-cicd.md +787 -0
- package/expertise/infrastructure/index.md +27 -0
- package/expertise/performance/PROGRESS.md +50 -0
- package/expertise/performance/backend/api-latency.md +1204 -0
- package/expertise/performance/backend/background-jobs.md +506 -0
- package/expertise/performance/backend/connection-pooling.md +1209 -0
- package/expertise/performance/backend/database-query-optimization.md +515 -0
- package/expertise/performance/backend/index.md +23 -0
- package/expertise/performance/backend/rate-limiting-and-throttling.md +971 -0
- package/expertise/performance/foundations/algorithmic-complexity.md +954 -0
- package/expertise/performance/foundations/caching-strategies.md +489 -0
- package/expertise/performance/foundations/concurrency-and-parallelism.md +847 -0
- package/expertise/performance/foundations/index.md +24 -0
- package/expertise/performance/foundations/measuring-and-profiling.md +440 -0
- package/expertise/performance/foundations/memory-management.md +964 -0
- package/expertise/performance/foundations/performance-budgets.md +1314 -0
- package/expertise/performance/index.md +31 -0
- package/expertise/performance/infrastructure/auto-scaling.md +1059 -0
- package/expertise/performance/infrastructure/cdn-and-edge.md +1081 -0
- package/expertise/performance/infrastructure/index.md +22 -0
- package/expertise/performance/infrastructure/load-balancing.md +1081 -0
- package/expertise/performance/infrastructure/observability.md +1079 -0
- package/expertise/performance/mobile/index.md +23 -0
- package/expertise/performance/mobile/mobile-animations.md +544 -0
- package/expertise/performance/mobile/mobile-memory-battery.md +416 -0
- package/expertise/performance/mobile/mobile-network.md +452 -0
- package/expertise/performance/mobile/mobile-rendering.md +599 -0
- package/expertise/performance/mobile/mobile-startup-time.md +505 -0
- package/expertise/performance/platform-specific/flutter-performance.md +647 -0
- package/expertise/performance/platform-specific/index.md +22 -0
- package/expertise/performance/platform-specific/node-performance.md +1307 -0
- package/expertise/performance/platform-specific/postgres-performance.md +1366 -0
- package/expertise/performance/platform-specific/react-performance.md +1403 -0
- package/expertise/performance/web/bundle-optimization.md +1239 -0
- package/expertise/performance/web/image-and-media.md +636 -0
- package/expertise/performance/web/index.md +24 -0
- package/expertise/performance/web/network-optimization.md +1133 -0
- package/expertise/performance/web/rendering-performance.md +1098 -0
- package/expertise/performance/web/ssr-and-hydration.md +918 -0
- package/expertise/performance/web/web-vitals.md +1374 -0
- package/expertise/quality/accessibility.md +985 -0
- package/expertise/quality/evidence-based-verification.md +499 -0
- package/expertise/quality/index.md +24 -0
- package/expertise/quality/ml-model-audit.md +614 -0
- package/expertise/quality/performance.md +600 -0
- package/expertise/quality/testing-api.md +891 -0
- package/expertise/quality/testing-mobile.md +496 -0
- package/expertise/quality/testing-web.md +849 -0
- package/expertise/security/PROGRESS.md +54 -0
- package/expertise/security/agentic-identity.md +540 -0
- package/expertise/security/compliance-frameworks.md +601 -0
- package/expertise/security/data/data-encryption.md +364 -0
- package/expertise/security/data/data-privacy-gdpr.md +692 -0
- package/expertise/security/data/database-security.md +1171 -0
- package/expertise/security/data/index.md +22 -0
- package/expertise/security/data/pii-handling.md +531 -0
- package/expertise/security/foundations/authentication.md +1041 -0
- package/expertise/security/foundations/authorization.md +603 -0
- package/expertise/security/foundations/cryptography.md +1001 -0
- package/expertise/security/foundations/index.md +25 -0
- package/expertise/security/foundations/owasp-top-10.md +1354 -0
- package/expertise/security/foundations/secrets-management.md +1217 -0
- package/expertise/security/foundations/secure-sdlc.md +700 -0
- package/expertise/security/foundations/supply-chain-security.md +698 -0
- package/expertise/security/index.md +31 -0
- package/expertise/security/infrastructure/cloud-security-aws.md +1296 -0
- package/expertise/security/infrastructure/cloud-security-gcp.md +1376 -0
- package/expertise/security/infrastructure/container-security.md +721 -0
- package/expertise/security/infrastructure/incident-response.md +1295 -0
- package/expertise/security/infrastructure/index.md +24 -0
- package/expertise/security/infrastructure/logging-and-monitoring.md +1618 -0
- package/expertise/security/infrastructure/network-security.md +1337 -0
- package/expertise/security/mobile/index.md +23 -0
- package/expertise/security/mobile/mobile-android-security.md +1218 -0
- package/expertise/security/mobile/mobile-binary-protection.md +1229 -0
- package/expertise/security/mobile/mobile-data-storage.md +1265 -0
- package/expertise/security/mobile/mobile-ios-security.md +1401 -0
- package/expertise/security/mobile/mobile-network-security.md +1520 -0
- package/expertise/security/smart-contract-security.md +594 -0
- package/expertise/security/testing/index.md +22 -0
- package/expertise/security/testing/penetration-testing.md +1258 -0
- package/expertise/security/testing/security-code-review.md +1765 -0
- package/expertise/security/testing/threat-modeling.md +1074 -0
- package/expertise/security/testing/vulnerability-scanning.md +1062 -0
- package/expertise/security/web/api-security.md +586 -0
- package/expertise/security/web/cors-and-headers.md +433 -0
- package/expertise/security/web/csrf.md +562 -0
- package/expertise/security/web/file-upload.md +1477 -0
- package/expertise/security/web/index.md +25 -0
- package/expertise/security/web/injection.md +1375 -0
- package/expertise/security/web/session-management.md +1101 -0
- package/expertise/security/web/xss.md +1158 -0
- package/exports/README.md +17 -0
- package/exports/hosts/claude/.claude/agents/clarifier.md +42 -0
- package/exports/hosts/claude/.claude/agents/content-author.md +63 -0
- package/exports/hosts/claude/.claude/agents/designer.md +55 -0
- package/exports/hosts/claude/.claude/agents/executor.md +55 -0
- package/exports/hosts/claude/.claude/agents/learner.md +51 -0
- package/exports/hosts/claude/.claude/agents/planner.md +53 -0
- package/exports/hosts/claude/.claude/agents/researcher.md +43 -0
- package/exports/hosts/claude/.claude/agents/reviewer.md +54 -0
- package/exports/hosts/claude/.claude/agents/specifier.md +47 -0
- package/exports/hosts/claude/.claude/agents/verifier.md +71 -0
- package/exports/hosts/claude/.claude/commands/author.md +42 -0
- package/exports/hosts/claude/.claude/commands/clarify.md +38 -0
- package/exports/hosts/claude/.claude/commands/design-review.md +46 -0
- package/exports/hosts/claude/.claude/commands/design.md +44 -0
- package/exports/hosts/claude/.claude/commands/discover.md +37 -0
- package/exports/hosts/claude/.claude/commands/execute.md +48 -0
- package/exports/hosts/claude/.claude/commands/learn.md +38 -0
- package/exports/hosts/claude/.claude/commands/plan-review.md +42 -0
- package/exports/hosts/claude/.claude/commands/plan.md +39 -0
- package/exports/hosts/claude/.claude/commands/prepare-next.md +37 -0
- package/exports/hosts/claude/.claude/commands/review.md +40 -0
- package/exports/hosts/claude/.claude/commands/run-audit.md +41 -0
- package/exports/hosts/claude/.claude/commands/spec-challenge.md +41 -0
- package/exports/hosts/claude/.claude/commands/specify.md +38 -0
- package/exports/hosts/claude/.claude/commands/verify.md +37 -0
- package/exports/hosts/claude/.claude/settings.json +34 -0
- package/exports/hosts/claude/CLAUDE.md +19 -0
- package/exports/hosts/claude/export.manifest.json +38 -0
- package/exports/hosts/claude/host-package.json +67 -0
- package/exports/hosts/codex/AGENTS.md +19 -0
- package/exports/hosts/codex/export.manifest.json +38 -0
- package/exports/hosts/codex/host-package.json +41 -0
- package/exports/hosts/cursor/.cursor/hooks.json +16 -0
- package/exports/hosts/cursor/.cursor/rules/wazir-core.mdc +19 -0
- package/exports/hosts/cursor/export.manifest.json +38 -0
- package/exports/hosts/cursor/host-package.json +42 -0
- package/exports/hosts/gemini/GEMINI.md +19 -0
- package/exports/hosts/gemini/export.manifest.json +38 -0
- package/exports/hosts/gemini/host-package.json +41 -0
- package/hooks/README.md +18 -0
- package/hooks/definitions/loop_cap_guard.yaml +21 -0
- package/hooks/definitions/post_tool_capture.yaml +24 -0
- package/hooks/definitions/pre_compact_summary.yaml +19 -0
- package/hooks/definitions/pre_tool_capture_route.yaml +19 -0
- package/hooks/definitions/protected_path_write_guard.yaml +19 -0
- package/hooks/definitions/session_start.yaml +19 -0
- package/hooks/definitions/stop_handoff_harvest.yaml +20 -0
- package/hooks/loop-cap-guard +17 -0
- package/hooks/post-tool-lint +36 -0
- package/hooks/protected-path-write-guard +17 -0
- package/hooks/session-start +41 -0
- package/llms-full.txt +2355 -0
- package/llms.txt +43 -0
- package/package.json +79 -0
- package/roles/README.md +20 -0
- package/roles/clarifier.md +42 -0
- package/roles/content-author.md +63 -0
- package/roles/designer.md +55 -0
- package/roles/executor.md +55 -0
- package/roles/learner.md +51 -0
- package/roles/planner.md +53 -0
- package/roles/researcher.md +43 -0
- package/roles/reviewer.md +54 -0
- package/roles/specifier.md +47 -0
- package/roles/verifier.md +71 -0
- package/schemas/README.md +24 -0
- package/schemas/accepted-learning.schema.json +20 -0
- package/schemas/author-artifact.schema.json +156 -0
- package/schemas/clarification.schema.json +19 -0
- package/schemas/design-artifact.schema.json +80 -0
- package/schemas/docs-claim.schema.json +18 -0
- package/schemas/export-manifest.schema.json +20 -0
- package/schemas/hook.schema.json +67 -0
- package/schemas/host-export-package.schema.json +18 -0
- package/schemas/implementation-plan.schema.json +19 -0
- package/schemas/proposed-learning.schema.json +19 -0
- package/schemas/research.schema.json +18 -0
- package/schemas/review.schema.json +29 -0
- package/schemas/run-manifest.schema.json +18 -0
- package/schemas/spec-challenge.schema.json +18 -0
- package/schemas/spec.schema.json +20 -0
- package/schemas/usage.schema.json +102 -0
- package/schemas/verification-proof.schema.json +29 -0
- package/schemas/wazir-manifest.schema.json +173 -0
- package/skills/README.md +40 -0
- package/skills/brainstorming/SKILL.md +77 -0
- package/skills/debugging/SKILL.md +50 -0
- package/skills/design/SKILL.md +61 -0
- package/skills/dispatching-parallel-agents/SKILL.md +128 -0
- package/skills/executing-plans/SKILL.md +70 -0
- package/skills/finishing-a-development-branch/SKILL.md +169 -0
- package/skills/humanize/SKILL.md +123 -0
- package/skills/init-pipeline/SKILL.md +124 -0
- package/skills/prepare-next/SKILL.md +20 -0
- package/skills/receiving-code-review/SKILL.md +123 -0
- package/skills/requesting-code-review/SKILL.md +105 -0
- package/skills/requesting-code-review/code-reviewer.md +108 -0
- package/skills/run-audit/SKILL.md +197 -0
- package/skills/scan-project/SKILL.md +41 -0
- package/skills/self-audit/SKILL.md +153 -0
- package/skills/subagent-driven-development/SKILL.md +154 -0
- package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +26 -0
- package/skills/subagent-driven-development/implementer-prompt.md +102 -0
- package/skills/subagent-driven-development/spec-reviewer-prompt.md +61 -0
- package/skills/tdd/SKILL.md +23 -0
- package/skills/using-git-worktrees/SKILL.md +163 -0
- package/skills/using-skills/SKILL.md +95 -0
- package/skills/verification/SKILL.md +22 -0
- package/skills/wazir/SKILL.md +463 -0
- package/skills/writing-plans/SKILL.md +30 -0
- package/skills/writing-skills/SKILL.md +157 -0
- package/skills/writing-skills/anthropic-best-practices.md +122 -0
- package/skills/writing-skills/persuasion-principles.md +50 -0
- package/templates/README.md +20 -0
- package/templates/artifacts/README.md +10 -0
- package/templates/artifacts/accepted-learning.md +19 -0
- package/templates/artifacts/accepted-learning.template.json +12 -0
- package/templates/artifacts/author.md +74 -0
- package/templates/artifacts/author.template.json +19 -0
- package/templates/artifacts/clarification.md +21 -0
- package/templates/artifacts/clarification.template.json +12 -0
- package/templates/artifacts/execute-notes.md +19 -0
- package/templates/artifacts/implementation-plan.md +21 -0
- package/templates/artifacts/implementation-plan.template.json +11 -0
- package/templates/artifacts/learning-proposal.md +19 -0
- package/templates/artifacts/next-run-handoff.md +21 -0
- package/templates/artifacts/plan-review.md +19 -0
- package/templates/artifacts/proposed-learning.template.json +12 -0
- package/templates/artifacts/research.md +21 -0
- package/templates/artifacts/research.template.json +12 -0
- package/templates/artifacts/review-findings.md +19 -0
- package/templates/artifacts/review.template.json +11 -0
- package/templates/artifacts/run-manifest.template.json +8 -0
- package/templates/artifacts/spec-challenge.md +19 -0
- package/templates/artifacts/spec-challenge.template.json +11 -0
- package/templates/artifacts/spec.md +21 -0
- package/templates/artifacts/spec.template.json +12 -0
- package/templates/artifacts/verification-proof.md +19 -0
- package/templates/artifacts/verification-proof.template.json +11 -0
- package/templates/examples/accepted-learning.example.json +14 -0
- package/templates/examples/author.example.json +152 -0
- package/templates/examples/clarification.example.json +15 -0
- package/templates/examples/docs-claim.example.json +8 -0
- package/templates/examples/export-manifest.example.json +7 -0
- package/templates/examples/host-export-package.example.json +11 -0
- package/templates/examples/implementation-plan.example.json +17 -0
- package/templates/examples/proposed-learning.example.json +13 -0
- package/templates/examples/research.example.json +15 -0
- package/templates/examples/research.example.md +6 -0
- package/templates/examples/review.example.json +17 -0
- package/templates/examples/run-manifest.example.json +9 -0
- package/templates/examples/spec-challenge.example.json +14 -0
- package/templates/examples/spec.example.json +21 -0
- package/templates/examples/verification-proof.example.json +21 -0
- package/templates/examples/wazir-manifest.example.yaml +65 -0
- package/templates/task-definition-schema.md +99 -0
- package/tooling/README.md +20 -0
- package/tooling/src/adapters/context-mode.js +50 -0
- package/tooling/src/capture/command.js +376 -0
- package/tooling/src/capture/store.js +99 -0
- package/tooling/src/capture/usage.js +270 -0
- package/tooling/src/checks/branches.js +50 -0
- package/tooling/src/checks/brand-truth.js +110 -0
- package/tooling/src/checks/changelog.js +231 -0
- package/tooling/src/checks/command-registry.js +36 -0
- package/tooling/src/checks/commits.js +102 -0
- package/tooling/src/checks/docs-drift.js +103 -0
- package/tooling/src/checks/docs-truth.js +201 -0
- package/tooling/src/checks/runtime-surface.js +156 -0
- package/tooling/src/cli.js +116 -0
- package/tooling/src/command-options.js +56 -0
- package/tooling/src/commands/validate.js +320 -0
- package/tooling/src/doctor/command.js +91 -0
- package/tooling/src/export/command.js +77 -0
- package/tooling/src/export/compiler.js +498 -0
- package/tooling/src/guards/loop-cap-guard.js +52 -0
- package/tooling/src/guards/protected-path-write-guard.js +67 -0
- package/tooling/src/index/command.js +152 -0
- package/tooling/src/index/storage.js +1061 -0
- package/tooling/src/index/summarizers.js +261 -0
- package/tooling/src/loaders.js +18 -0
- package/tooling/src/project-root.js +22 -0
- package/tooling/src/recall/command.js +225 -0
- package/tooling/src/schema-validator.js +30 -0
- package/tooling/src/state-root.js +40 -0
- package/tooling/src/status/command.js +71 -0
- package/wazir.manifest.yaml +135 -0
- package/workflows/README.md +19 -0
- package/workflows/author.md +42 -0
- package/workflows/clarify.md +38 -0
- package/workflows/design-review.md +46 -0
- package/workflows/design.md +44 -0
- package/workflows/discover.md +37 -0
- package/workflows/execute.md +48 -0
- package/workflows/learn.md +38 -0
- package/workflows/plan-review.md +42 -0
- package/workflows/plan.md +39 -0
- package/workflows/prepare-next.md +37 -0
- package/workflows/review.md +40 -0
- package/workflows/run-audit.md +41 -0
- package/workflows/spec-challenge.md +41 -0
- package/workflows/specify.md +38 -0
- package/workflows/verify.md +37 -0
|
@@ -0,0 +1,780 @@
|
|
|
1
|
+
# Serverless Architecture — Architecture Expertise Module
|
|
2
|
+
|
|
3
|
+
> Serverless (FaaS) lets you run code without managing servers, with auto-scaling and pay-per-invocation. Not "no servers" — "someone else's servers, billed by execution." Excellent for event-driven, variable-load workloads; wrong for latency-sensitive or long-running processes.
|
|
4
|
+
|
|
5
|
+
> **Category:** Pattern
|
|
6
|
+
> **Complexity:** Moderate
|
|
7
|
+
> **Applies when:** Event-driven workloads, variable/spiky traffic, background processing, APIs with unpredictable load
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## What This Is (and What It Isn't)
|
|
12
|
+
|
|
13
|
+
Serverless computing is an execution model where the cloud provider dynamically manages the allocation and provisioning of servers. Your code runs in **stateless, ephemeral compute containers** that are event-triggered, fully managed, and billed by actual consumption (invocations x duration x memory), not by reserved capacity.
|
|
14
|
+
|
|
15
|
+
There are two distinct categories within "serverless":
|
|
16
|
+
|
|
17
|
+
| Category | What it means | Examples |
|
|
18
|
+
|---|---|---|
|
|
19
|
+
| **FaaS** (Function as a Service) | You deploy individual functions. The platform handles execution, scaling, and teardown. | AWS Lambda, Google Cloud Functions, Azure Functions, Cloudflare Workers |
|
|
20
|
+
| **BaaS** (Backend as a Service) | You consume fully managed backend services via APIs — no server code at all. | Firebase, AWS AppSync, Auth0, Supabase, Algolia |
|
|
21
|
+
|
|
22
|
+
This module focuses primarily on **FaaS**, though BaaS services are often combined with FaaS to form a complete serverless architecture.
|
|
23
|
+
|
|
24
|
+
### The execution model
|
|
25
|
+
|
|
26
|
+
A serverless function follows this lifecycle on every invocation:
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
Request arrives
|
|
30
|
+
|
|
|
31
|
+
v
|
|
32
|
+
[Cold start?] --yes--> Provision container --> Download code --> Initialize runtime --> Run INIT code
|
|
33
|
+
| |
|
|
34
|
+
no |
|
|
35
|
+
| v
|
|
36
|
+
+---> [Warm container exists] --> Run handler code --> Return response --> Container idles
|
|
37
|
+
|
|
|
38
|
+
(idle timeout: ~5-15 min)
|
|
39
|
+
|
|
|
40
|
+
v
|
|
41
|
+
Container destroyed
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Key properties of a serverless function:
|
|
45
|
+
|
|
46
|
+
- **Stateless.** No local state survives between invocations. Any state must be stored externally (DynamoDB, S3, Redis).
|
|
47
|
+
- **Ephemeral.** Containers are created and destroyed by the platform. You cannot SSH in, you cannot assume persistence.
|
|
48
|
+
- **Time-limited.** AWS Lambda: 15 minutes max. Google Cloud Functions: 9 minutes (1st gen) / 60 minutes (2nd gen). Azure Functions: 10 minutes default, 60 minutes on Premium plan.
|
|
49
|
+
- **Memory-bounded.** Lambda: 128 MB to 10,240 MB. CPU scales proportionally with memory (no independent CPU control).
|
|
50
|
+
- **Concurrency-managed.** The platform decides how many instances run. Default account-level concurrency: 1,000 on Lambda (soft limit, raisable to tens of thousands).
|
|
51
|
+
|
|
52
|
+
### What it is not
|
|
53
|
+
|
|
54
|
+
- **"No servers."** There are absolutely servers. You just do not manage them. AWS runs your code on EC2 instances inside Firecracker microVMs. You pay for someone else to handle provisioning, patching, scaling, and fault tolerance.
|
|
55
|
+
- **"Always cheaper."** For steady, high-throughput workloads, serverless is often **more expensive** than containers or VMs. Pay-per-invocation adds up when you have 100+ requests per second around the clock.
|
|
56
|
+
- **"Simpler."** The function code is simpler. The surrounding architecture — triggers, permissions, event schemas, DLQs, retries, observability — is more complex than a traditional deployment. Local development and debugging are significantly harder.
|
|
57
|
+
- **"The future of all computing."** Serverless is excellent for a specific class of workloads. It is the wrong tool for long-running processes, latency-critical hot paths, stateful workloads, and GPU-intensive computation.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## When to Use It
|
|
62
|
+
|
|
63
|
+
### Event-driven processing
|
|
64
|
+
|
|
65
|
+
Serverless is the natural fit when work arrives as discrete events: an image uploaded to S3, a message published to a queue, a row inserted into a database, a webhook received from a third-party service. The function wakes up, processes the event, and goes back to sleep. You pay nothing when no events arrive.
|
|
66
|
+
|
|
67
|
+
**Real example — iRobot:** iRobot uses AWS Lambda for its smart home platform. Every Roomba robot sends telemetry data via AWS IoT Core. Lambda functions process real-time data streams from Kinesis, run cleaning-schedule logic, and push firmware updates. The fleet scales from thousands to millions of active robots without capacity planning.
|
|
68
|
+
|
|
69
|
+
### Scheduled jobs and background tasks
|
|
70
|
+
|
|
71
|
+
Cron-style workloads — nightly report generation, hourly data syncs, periodic cleanup — are ideal. A CloudWatch Events rule triggers a Lambda at 2 AM, it runs for 3 minutes, and you pay for 3 minutes. Compared to a 24/7 EC2 instance running a cron daemon, the savings are dramatic.
|
|
72
|
+
|
|
73
|
+
### Spiky and unpredictable traffic
|
|
74
|
+
|
|
75
|
+
If your traffic pattern has a 10x or greater ratio between peak and baseline, serverless auto-scaling eliminates the need to over-provision for peaks or under-provision during troughs.
|
|
76
|
+
|
|
77
|
+
**Real example — Coca-Cola:** Coca-Cola migrated its vending machine payment processing to AWS Lambda and API Gateway. Each payment request triggers a Lambda function. Traffic is inherently spiky — lunchtime rushes, event venues, seasonal patterns. The migration saved **65% in infrastructure costs** because they stopped paying for idle capacity during off-peak hours.
|
|
78
|
+
|
|
79
|
+
### Low-traffic APIs and MVPs
|
|
80
|
+
|
|
81
|
+
An API that receives 10,000 requests per day costs virtually nothing on Lambda (often within the free tier). For startups validating product-market fit, serverless eliminates the fixed cost of keeping a server running 24/7 while you have 12 users.
|
|
82
|
+
|
|
83
|
+
### Data transformation pipelines
|
|
84
|
+
|
|
85
|
+
ETL jobs that transform data between systems — CSV upload to S3 triggers parsing, validation, enrichment, and loading into a data warehouse — map naturally to function chains. Each step is an independent function triggered by the completion of the previous step.
|
|
86
|
+
|
|
87
|
+
**Real example — Financial Times:** The Financial Times uses serverless for content processing pipelines. Article ingestion, image resizing, metadata enrichment, and search indexing all run as Lambda functions triggered by content events. The editorial system handles unpredictable publishing patterns (breaking news spikes) without manual scaling.
|
|
88
|
+
|
|
89
|
+
### Glue code and integrations
|
|
90
|
+
|
|
91
|
+
Connecting SaaS products, translating between APIs, handling webhooks — small, infrequent tasks that do not justify a dedicated service. A Lambda function that receives a Stripe webhook, formats a Slack notification, and updates a database row is the canonical example.
|
|
92
|
+
|
|
93
|
+
**Real example — Airbnb:** Airbnb uses AWS Lambda and CloudWatch to automate security audits, system monitoring, and log processing. Lambda functions analyze logs and send alerts when unusual activity is detected, reducing manual monitoring efforts by 60%.
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## When NOT to Use It
|
|
98
|
+
|
|
99
|
+
This section is equally important. Serverless zealotry has caused real damage in production systems.
|
|
100
|
+
|
|
101
|
+
### Latency-sensitive hot paths (cold starts are real)
|
|
102
|
+
|
|
103
|
+
Cold starts add **200ms to 1+ seconds** of latency on the first invocation after a period of inactivity. The severity depends on runtime and configuration:
|
|
104
|
+
|
|
105
|
+
| Runtime | Typical cold start (no VPC) | With VPC | With SnapStart |
|
|
106
|
+
|---|---|---|---|
|
|
107
|
+
| Python | 150–300 ms | 300–500 ms | N/A (not yet) |
|
|
108
|
+
| Node.js | 150–300 ms | 300–500 ms | N/A |
|
|
109
|
+
| Go | 50–100 ms | 200–400 ms | N/A |
|
|
110
|
+
| Java | 800 ms–3 s | 2–6 s | 200–400 ms |
|
|
111
|
+
| .NET | 400–800 ms | 1–3 s | 200–400 ms |
|
|
112
|
+
|
|
113
|
+
If your SLA requires p99 latency under 100ms — a trading system, a real-time bidding platform, a game server — serverless cannot deliver this without provisioned concurrency, which eliminates the cost advantage.
|
|
114
|
+
|
|
115
|
+
**Critical 2025 change:** As of August 2025, AWS bills for the Lambda INIT phase (the cold start initialization). Cold starts are now a cost factor in addition to a performance factor. For Java functions without SnapStart, this can increase Lambda spend by 10-50%.
|
|
116
|
+
|
|
117
|
+
### Long-running processes (the 15-minute wall)
|
|
118
|
+
|
|
119
|
+
AWS Lambda hard-caps execution at 15 minutes. If your workload involves video transcoding, ML model training, large data migrations, or any task that runs for hours, Lambda is architecturally incompatible. You can break work into 15-minute chunks, but the orchestration complexity often exceeds the benefit.
|
|
120
|
+
|
|
121
|
+
### High-frequency steady traffic (containers are cheaper)
|
|
122
|
+
|
|
123
|
+
When average CPU utilization stays above ~20% continuously, containers on ECS/Fargate or Kubernetes become more cost-effective. An API consistently handling 100 requests per second around the clock is cheaper on a $50/month container than on Lambda at ~$260 million invocations/month.
|
|
124
|
+
|
|
125
|
+
**The cost crossover:** Industry benchmarks consistently show that above approximately 10 million requests per day with steady load, containerized deployment costs less than Lambda. Below 1 million requests per day with variable load, Lambda costs less. The 1-10M range depends on traffic pattern.
|
|
126
|
+
|
|
127
|
+
### When you need full runtime control
|
|
128
|
+
|
|
129
|
+
Serverless functions run in a constrained environment. You cannot:
|
|
130
|
+
|
|
131
|
+
- Install system-level packages (beyond what Lambda layers provide)
|
|
132
|
+
- Control the underlying OS or kernel parameters
|
|
133
|
+
- Run multiple processes or background threads reliably
|
|
134
|
+
- Use the local filesystem for anything beyond `/tmp` (512 MB default, 10 GB max)
|
|
135
|
+
- Open listening sockets (you cannot run a WebSocket server in Lambda)
|
|
136
|
+
|
|
137
|
+
### Vendor lock-in is a real constraint
|
|
138
|
+
|
|
139
|
+
A Lambda function that uses API Gateway triggers, DynamoDB streams, SQS dead-letter queues, and Step Functions orchestration is deeply coupled to AWS. Migrating to Google Cloud or Azure requires rewriting not just the functions, but the entire event-driven architecture around them. The Serverless Framework and SST abstract some of this, but the abstraction is leaky.
|
|
140
|
+
|
|
141
|
+
### Local development is painful
|
|
142
|
+
|
|
143
|
+
There is no local equivalent of "run the server and hit it with curl." LocalStack simulates AWS services but has gaps and behavioral differences. SAM Local provides Lambda emulation but cannot replicate event source mappings, IAM permissions, or VPC networking. The feedback loop for serverless development is slower than `docker-compose up`.
|
|
144
|
+
|
|
145
|
+
### The Prime Video case study: when serverless is the wrong tool
|
|
146
|
+
|
|
147
|
+
In 2023, Amazon Prime Video published a widely discussed case study. Their video quality inspection service — which analyzed every stream for visual defects — was built on AWS Step Functions and Lambda. **The architecture hit a hard scaling limit at 5% of expected load.** The problems:
|
|
148
|
+
|
|
149
|
+
1. **Step Functions state transitions were too frequent.** Every video frame analysis required a state transition, and Step Functions charges per state transition ($0.025 per 1,000). At millions of frames per day, this became prohibitively expensive.
|
|
150
|
+
2. **Lambda-to-S3 calls were chatty.** Intermediate results were stored in and read from S3 between function invocations, creating massive I/O overhead.
|
|
151
|
+
3. **Orchestration overhead exceeded computation.** More time and money was spent coordinating functions than doing actual video analysis.
|
|
152
|
+
|
|
153
|
+
The team moved to a monolithic application on Amazon ECS. **Infrastructure cost dropped by 90%.** Scaling capabilities increased.
|
|
154
|
+
|
|
155
|
+
**The lesson is not "serverless is bad."** The lesson is that serverless was the wrong architecture for a high-frequency, tightly coupled data pipeline that processes every frame of every video stream. The team used serverless for rapid prototyping (which was correct), then failed to recognize when the workload outgrew the model.
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## How It Works
|
|
160
|
+
|
|
161
|
+
### Function lifecycle in detail
|
|
162
|
+
|
|
163
|
+
**1. Cold start (INIT phase):**
|
|
164
|
+
|
|
165
|
+
When no warm container is available, the platform must:
|
|
166
|
+
|
|
167
|
+
1. **Provision a Firecracker microVM** (AWS) or V8 isolate (Cloudflare Workers)
|
|
168
|
+
2. **Download the deployment package** from S3 (or use a cached copy)
|
|
169
|
+
3. **Initialize the runtime** (start the Node.js/Python/Java process)
|
|
170
|
+
4. **Execute initialization code** — everything outside the handler function (imports, database connections, SDK client creation)
|
|
171
|
+
|
|
172
|
+
Best practice: move expensive initialization (database connections, SDK clients, configuration loading) **outside** the handler. This code runs once per container lifecycle, not once per invocation.
|
|
173
|
+
|
|
174
|
+
```python
|
|
175
|
+
# GOOD: Connection created once per container (during INIT)
|
|
176
|
+
import boto3
|
|
177
|
+
dynamodb = boto3.resource('dynamodb')
|
|
178
|
+
table = dynamodb.Table('users')
|
|
179
|
+
|
|
180
|
+
def handler(event, context):
|
|
181
|
+
# This runs on every invocation, but `table` is already warm
|
|
182
|
+
return table.get_item(Key={'id': event['user_id']})
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
```python
|
|
186
|
+
# BAD: Connection created on every invocation
|
|
187
|
+
def handler(event, context):
|
|
188
|
+
import boto3 # Re-imported every time
|
|
189
|
+
dynamodb = boto3.resource('dynamodb') # New client every time
|
|
190
|
+
table = dynamodb.Table('users') # New table reference every time
|
|
191
|
+
return table.get_item(Key={'id': event['user_id']})
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
**2. Invocation (INVOKE phase):**
|
|
195
|
+
|
|
196
|
+
The handler function receives the event payload and a context object. It executes, returns a response, and the container enters an idle state. The container remains warm for approximately 5-15 minutes (AWS does not document the exact timeout and it varies).
|
|
197
|
+
|
|
198
|
+
**3. Shutdown:**
|
|
199
|
+
|
|
200
|
+
After the idle timeout, the platform destroys the container. Any state in memory, any files in `/tmp`, any open connections — gone.
|
|
201
|
+
|
|
202
|
+
### Cold start mitigation strategies
|
|
203
|
+
|
|
204
|
+
| Strategy | How it works | Cost impact | Effectiveness |
|
|
205
|
+
|---|---|---|---|
|
|
206
|
+
| **Provisioned concurrency** | Pre-warms N containers permanently | $15-30/month per 512MB instance | Eliminates cold starts entirely |
|
|
207
|
+
| **SnapStart** (Java, Python, .NET) | Snapshots the initialized state, restores from snapshot | Minimal (storage cost) | Reduces cold starts by ~90% |
|
|
208
|
+
| **Smaller packages** | Fewer dependencies = faster download + init | None | Moderate improvement |
|
|
209
|
+
| **Arm64 (Graviton)** | ARM-based instances start faster and cost 20% less | 20% savings | Measurable improvement |
|
|
210
|
+
| **Keep-warm pings** | CloudWatch rule invokes function every 5 min | Minimal invocation cost | Works for single-concurrency only |
|
|
211
|
+
| **Language choice** | Go/Rust: ~50ms cold start. Java: ~2s without SnapStart | None | Significant for cold-start-sensitive paths |
|
|
212
|
+
|
|
213
|
+
### Invocation types
|
|
214
|
+
|
|
215
|
+
Lambda supports three invocation models, and choosing the wrong one causes subtle bugs:
|
|
216
|
+
|
|
217
|
+
| Type | Behavior | Retry on failure | Use case |
|
|
218
|
+
|---|---|---|---|
|
|
219
|
+
| **Synchronous** | Caller waits for response | No automatic retry (caller must retry) | API Gateway, SDK `invoke()` |
|
|
220
|
+
| **Asynchronous** | Caller gets 202 immediately, Lambda retries | 2 automatic retries with backoff | S3 events, SNS, CloudWatch Events |
|
|
221
|
+
| **Event source mapping** | Lambda polls a stream/queue | Retries until record expires or succeeds | SQS, Kinesis, DynamoDB Streams |
|
|
222
|
+
|
|
223
|
+
### Concurrency model
|
|
224
|
+
|
|
225
|
+
Each concurrent invocation runs in its own container. If 100 requests arrive simultaneously, Lambda spins up 100 containers (subject to concurrency limits).
|
|
226
|
+
|
|
227
|
+
- **Account-level default:** 1,000 concurrent executions (soft limit)
|
|
228
|
+
- **Burst concurrency:** 500-3,000 immediate, then 500 additional per minute (varies by region)
|
|
229
|
+
- **Reserved concurrency:** Guarantees capacity for a specific function but limits its maximum
|
|
230
|
+
- **Provisioned concurrency:** Pre-warms containers for instant start
|
|
231
|
+
|
|
232
|
+
**The concurrency trap:** If your function calls a database with a 100-connection pool, and Lambda scales to 500 concurrent instances, you have 500 functions each trying to open a database connection against a pool of 100. The database falls over. Solution: use RDS Proxy or connection pooling middleware.
|
|
233
|
+
|
|
234
|
+
### Error handling and Dead Letter Queues (DLQ)
|
|
235
|
+
|
|
236
|
+
For asynchronous invocations, Lambda retries failed executions twice. After all retries are exhausted, the event is sent to a configured DLQ (an SQS queue or SNS topic). Without a DLQ, **failed events are silently dropped.**
|
|
237
|
+
|
|
238
|
+
```yaml
|
|
239
|
+
# serverless.yml - always configure a DLQ
|
|
240
|
+
functions:
|
|
241
|
+
processOrder:
|
|
242
|
+
handler: orders.handler
|
|
243
|
+
events:
|
|
244
|
+
- sqs:
|
|
245
|
+
arn: !GetAtt OrderQueue.Arn
|
|
246
|
+
deadLetterQueue:
|
|
247
|
+
targetArn: !GetAtt OrderDLQ.Arn
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
Lambda Destinations (introduced 2019) provide a more flexible alternative to DLQs, allowing you to route both successful and failed invocations to different targets (SQS, SNS, Lambda, EventBridge).
|
|
251
|
+
|
|
252
|
+
### Layers
|
|
253
|
+
|
|
254
|
+
Lambda Layers allow you to package shared libraries, custom runtimes, or common dependencies separately from your function code. A layer is a ZIP archive that gets extracted into `/opt` in the execution environment.
|
|
255
|
+
|
|
256
|
+
- Maximum 5 layers per function
|
|
257
|
+
- Total unzipped size (function + all layers): 250 MB
|
|
258
|
+
- Layers are versioned and immutable
|
|
259
|
+
|
|
260
|
+
Use layers for: shared utility code across functions, large dependencies (numpy, pandas), custom runtimes.
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## Trade-Offs Matrix
|
|
265
|
+
|
|
266
|
+
| Dimension | Serverless (FaaS) | Containers (ECS/K8s) | Notes |
|
|
267
|
+
|---|---|---|---|
|
|
268
|
+
| **Scaling** | Automatic, per-request, near-instant | Manual/auto-scaling, pod-level, slower | Serverless scales to zero; containers have minimum replica count |
|
|
269
|
+
| **Cold start latency** | 50ms–3s depending on runtime | None (containers are always running) | Critical for user-facing APIs with strict SLAs |
|
|
270
|
+
| **Cost at low traffic** | Near-zero (pay only for invocations) | Fixed cost (minimum container always running) | Serverless wins dramatically below ~1M req/day |
|
|
271
|
+
| **Cost at high traffic** | Expensive (per-invocation adds up) | Cheaper (amortized over sustained load) | Containers win above ~10M req/day steady load |
|
|
272
|
+
| **Operational overhead** | Near-zero (no patching, no capacity planning) | Significant (cluster management, upgrades, monitoring) | Serverless trades control for convenience |
|
|
273
|
+
| **Execution time limit** | 15 min (Lambda), varies by platform | Unlimited | Hard blocker for long-running processes |
|
|
274
|
+
| **Local development** | Difficult (emulators are incomplete) | Excellent (docker-compose) | Biggest developer experience gap |
|
|
275
|
+
| **Vendor lock-in** | High (event sources, IAM, triggers are platform-specific) | Low-moderate (OCI containers are portable) | Serverless lock-in is in the glue, not the function code |
|
|
276
|
+
| **Observability** | Harder (distributed traces across functions) | Easier (centralized logging, APM agents) | Serverless requires specialized tooling (X-Ray, Datadog) |
|
|
277
|
+
| **Stateful workloads** | Not supported (external state only) | Supported (persistent volumes, local state) | Serverless is fundamentally stateless |
|
|
278
|
+
| **Language flexibility** | Limited to supported runtimes (or custom runtimes) | Any language, any version, any system dependency | Custom runtimes add complexity on Lambda |
|
|
279
|
+
| **Security patching** | Managed by provider (for supported runtimes) | Your responsibility (base images, OS, dependencies) | Serverless reduces security surface area |
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## Evolution Path
|
|
284
|
+
|
|
285
|
+
The most successful serverless architectures follow a deliberate evolution, not a big-bang adoption.
|
|
286
|
+
|
|
287
|
+
### Phase 1: Start serverless for event-driven and glue
|
|
288
|
+
|
|
289
|
+
Begin with workloads that are naturally event-driven: webhook handlers, file processing, scheduled tasks, notification dispatching. These have variable load, short execution times, and no latency requirements. The cost advantage is clear and the operational simplicity is real.
|
|
290
|
+
|
|
291
|
+
```
|
|
292
|
+
[S3 Upload] --> [Lambda: resize image] --> [S3: store thumbnail]
|
|
293
|
+
[Stripe Webhook] --> [Lambda: update DB + notify Slack]
|
|
294
|
+
[CloudWatch Cron] --> [Lambda: generate daily report] --> [SES: email report]
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### Phase 2: Expand to APIs with caveats
|
|
298
|
+
|
|
299
|
+
Build API endpoints on Lambda + API Gateway for low-to-moderate traffic APIs. Accept the cold start tradeoff for non-latency-critical endpoints. Use provisioned concurrency for critical paths.
|
|
300
|
+
|
|
301
|
+
```
|
|
302
|
+
[API Gateway] --> [Lambda: /api/users] --> [DynamoDB]
|
|
303
|
+
[API Gateway] --> [Lambda: /api/orders] --> [RDS via RDS Proxy]
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
### Phase 3: Identify hot paths and migrate selectively
|
|
307
|
+
|
|
308
|
+
Monitor invocation frequency, duration, and cost. When a function consistently runs at high concurrency with steady traffic, it is a candidate for migration to a container. This is not a failure — it is the architecture maturing.
|
|
309
|
+
|
|
310
|
+
**Indicators a function should become a container:**
|
|
311
|
+
|
|
312
|
+
- Invocation count > 10 million/day with steady (not spiky) load
|
|
313
|
+
- p99 latency consistently violated by cold starts
|
|
314
|
+
- Execution duration regularly approaches the 15-minute limit
|
|
315
|
+
- Function requires persistent connections (WebSockets, gRPC streams)
|
|
316
|
+
- Cost exceeds what an equivalent Fargate task would cost
|
|
317
|
+
|
|
318
|
+
### Phase 4: Hybrid architecture (the pragmatic end state)
|
|
319
|
+
|
|
320
|
+
Most mature serverless architectures are actually hybrid:
|
|
321
|
+
|
|
322
|
+
```
|
|
323
|
+
+------------------+
|
|
324
|
+
| API Gateway |
|
|
325
|
+
+------------------+
|
|
326
|
+
/ | \
|
|
327
|
+
/ | \
|
|
328
|
+
+--------+ +--------+ +----------+
|
|
329
|
+
| Lambda | | Lambda | | Fargate |
|
|
330
|
+
| (auth) | | (CRUD) | | (search) |
|
|
331
|
+
+--------+ +--------+ +----------+
|
|
332
|
+
| | |
|
|
333
|
+
+--------+ +--------+ +----------+
|
|
334
|
+
| Cognito| |DynamoDB| |OpenSearch|
|
|
335
|
+
+--------+ +--------+ +----------+
|
|
336
|
+
|
|
337
|
+
[S3 events] --> [Lambda: process files]
|
|
338
|
+
[SQS queue] --> [Lambda: async tasks]
|
|
339
|
+
[EventBridge] --> [Lambda: scheduled jobs]
|
|
340
|
+
[ALB] --> [Fargate: long-running API, WebSockets]
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
The auth and CRUD endpoints stay on Lambda (variable traffic, short execution). The search endpoint moves to Fargate (requires persistent OpenSearch connections, consistent load). Background processing stays on Lambda (event-driven, naturally bursty).
|
|
344
|
+
|
|
345
|
+
---
|
|
346
|
+
|
|
347
|
+
## Failure Modes
|
|
348
|
+
|
|
349
|
+
### 1. Cold start cascades in function chains
|
|
350
|
+
|
|
351
|
+
A single user request might trigger 3-5 different Lambda functions in sequence (API Gateway -> Auth function -> Business logic function -> Notification function). If each has a 1% chance of a cold start, the probability that *something* in the chain is slow is approximately 5%. At scale, this means a persistent tail of slow requests that is extremely difficult to debug.
|
|
352
|
+
|
|
353
|
+
**The cascade effect:** When Function A cold-starts, it takes 2 seconds instead of 50ms. Function B's invocation is delayed. If Function B also cold-starts (because the delayed traffic pattern disrupts the warm pool), the total request time balloons to 4+ seconds. Users see intermittent, unpredictable slowness.
|
|
354
|
+
|
|
355
|
+
**Mitigation:** Minimize function chain depth. Use asynchronous invocation where possible so cold starts do not compound on the user-facing request path. Use provisioned concurrency on the entry-point function.
|
|
356
|
+
|
|
357
|
+
### 2. Timeout cliff at 15 minutes
|
|
358
|
+
|
|
359
|
+
Functions do not gracefully degrade as they approach the timeout — they are **hard-killed**. Any work in progress is lost. Any database transaction in flight is left uncommitted (or worse, partially committed if your code is not idempotent).
|
|
360
|
+
|
|
361
|
+
**The insidious version:** A function normally runs in 2 minutes. A downstream API (database, third-party service) becomes slow. The function now takes 16 minutes. It is killed. The retry runs. The downstream is still slow. It is killed again. The event goes to the DLQ. Meanwhile, the database has two partially-committed transactions.
|
|
362
|
+
|
|
363
|
+
**Mitigation:** Design functions to be idempotent. Use idempotency keys for database writes. Set function timeouts well below 15 minutes (e.g., 5 minutes) so you fail fast and retry rather than hanging for 15 minutes and losing work.
|
|
364
|
+
|
|
365
|
+
### 3. Concurrency limits causing throttling
|
|
366
|
+
|
|
367
|
+
Account-level concurrency defaults to 1,000. A traffic spike that requires 1,500 concurrent executions will cause 500 invocations to be throttled (429 errors for sync, retries for async). If multiple functions share the account, a runaway function can consume all concurrency and starve other functions.
|
|
368
|
+
|
|
369
|
+
**Real scenario:** A marketing team launches a campaign. Traffic to the public API spikes to 2,000 concurrent requests. The API functions consume all 1,000 concurrent executions. The payment processing function (also in this account) is throttled. Customers cannot complete purchases during the campaign.
|
|
370
|
+
|
|
371
|
+
**Mitigation:** Use reserved concurrency to guarantee capacity for critical functions. Request limit increases proactively. Separate production workloads into different AWS accounts.
|
|
372
|
+
|
|
373
|
+
### 4. Cost explosion from recursive loops
|
|
374
|
+
|
|
375
|
+
This is the serverless equivalent of a fork bomb. A Lambda function writes to an S3 bucket. An S3 event notification triggers the same Lambda function. The function writes to S3 again. Each invocation spawns another invocation. The function scales to thousands of concurrent instances in seconds.
|
|
376
|
+
|
|
377
|
+
**Real-world damage:** Engineers have reported waking up to $50,000 bills from overnight recursive loops. The scaling is so fast that budget alerts (which run on hourly or daily cadence) do not fire until the damage is done. You can go to bed with a $5 monthly bill and wake up with a $50,000 bill.
|
|
378
|
+
|
|
379
|
+
**AWS protection (since 2023):** Recursive Loop Detection automatically stops recursive invocations between Lambda, SQS, and SNS after approximately 16 loops. However, this only covers specific service combinations — custom recursive patterns are not detected.
|
|
380
|
+
|
|
381
|
+
**Mitigation:**
|
|
382
|
+
- Never write to the same S3 bucket/prefix that triggers the function
|
|
383
|
+
- Use a separate output bucket for processed results
|
|
384
|
+
- Set concurrency limits on functions to cap runaway scaling
|
|
385
|
+
- Configure CloudWatch billing alarms with low thresholds
|
|
386
|
+
- Add a recursion counter in the event payload and bail out after N iterations
|
|
387
|
+
|
|
388
|
+
### 5. Downstream service overwhelm
|
|
389
|
+
|
|
390
|
+
Lambda scales to hundreds or thousands of instances instantly. Your downstream database, third-party API, or legacy service does not. A traffic spike causes Lambda to scale to 500 instances, each opening a database connection. Your RDS instance has a 100-connection limit. The database rejects connections. All 500 Lambda invocations fail. They retry. The database is now under even more load.
|
|
391
|
+
|
|
392
|
+
**Mitigation:** Use RDS Proxy for database connections. Use SQS as a buffer between Lambda and rate-limited downstream services. Set reserved concurrency on functions to match downstream capacity.
|
|
393
|
+
|
|
394
|
+
### 6. Observability blind spots
|
|
395
|
+
|
|
396
|
+
In a monolith, a request flows through a single process — you can attach a debugger, read sequential logs, and trace the execution path. In serverless, a request touches API Gateway, Lambda (possibly multiple functions), DynamoDB, SQS, another Lambda, and SNS. Each component has its own logs in its own CloudWatch log group. Correlating a single request across all these services requires distributed tracing (X-Ray, Datadog) and disciplined correlation ID propagation.
|
|
397
|
+
|
|
398
|
+
**The debugging tax:** Engineers report spending 2-3x more time debugging serverless applications compared to equivalent container-based applications, primarily due to log fragmentation and the inability to reproduce issues locally.
|
|
399
|
+
|
|
400
|
+
---
|
|
401
|
+
|
|
402
|
+
## Technology Landscape
|
|
403
|
+
|
|
404
|
+
### Major platforms
|
|
405
|
+
|
|
406
|
+
| Platform | Provider | Runtime model | Cold start | Max duration | Key strength |
|
|
407
|
+
|---|---|---|---|---|---|
|
|
408
|
+
| **AWS Lambda** | AWS | Firecracker microVM | 50ms–3s | 15 min | Deepest ecosystem integration (200+ event sources) |
|
|
409
|
+
| **Google Cloud Functions** | GCP | gVisor container | 100ms–1s | 9 min (1st gen), 60 min (2nd gen) | Tight integration with Firebase, BigQuery |
|
|
410
|
+
| **Azure Functions** | Microsoft | Container-based | 100ms–2s | 5-10 min (Consumption), 60 min (Premium) | Best for .NET workloads, hybrid with Azure Arc |
|
|
411
|
+
| **Cloudflare Workers** | Cloudflare | V8 isolates | <5ms | 30s (free), 15 min (paid) | Zero cold starts, 300+ edge locations, 441% faster than Lambda at p95 |
|
|
412
|
+
| **Vercel Functions** | Vercel | AWS Lambda (underneath) | Similar to Lambda | 10s (Hobby), 5 min (Pro) | Best DX for Next.js/React, Fluid compute model |
|
|
413
|
+
| **Deno Deploy** | Deno | V8 isolates | <5ms | 50ms wall (free), unlimited (paid) | TypeScript-native, edge-first |
|
|
414
|
+
|
|
415
|
+
### Edge compute: the cold-start killer
|
|
416
|
+
|
|
417
|
+
Cloudflare Workers and similar edge platforms (Deno Deploy, Vercel Edge Functions, Fastly Compute) use **V8 isolates** instead of containers. A V8 isolate starts in under 5 milliseconds with a tenth of the memory overhead of a full Node.js process. At the 95th percentile, Workers is **441% faster** than Lambda and **192% faster** than Lambda@Edge.
|
|
418
|
+
|
|
419
|
+
The tradeoff: edge runtimes are constrained. Workers support JavaScript/TypeScript/Wasm only, have 128 MB memory (not configurable), and cannot access VPC resources or most AWS services natively.
|
|
420
|
+
|
|
421
|
+
**The winning architecture in 2025** uses both: edge functions for routing, authentication, personalization, and caching; traditional serverless (Lambda) for heavy computation and deep cloud integrations.
|
|
422
|
+
|
|
423
|
+
### Frameworks and tooling
|
|
424
|
+
|
|
425
|
+
| Tool | Purpose | Status (2025-2026) |
|
|
426
|
+
|---|---|---|
|
|
427
|
+
| **SST (Serverless Stack)** | TypeScript-first IaC framework built on AWS CDK. Live Lambda Dev for local debugging. | Active but development slowing. v3 stable, maintenance mode. Excellent DX, uncertain long-term investment. |
|
|
428
|
+
| **Serverless Framework** | The original serverless deployment tool. YAML-based, multi-cloud. | Mature, widely adopted. v4 introduced a dashboard with paid tier, causing community friction. |
|
|
429
|
+
| **AWS SAM** | AWS-native serverless framework. CloudFormation-based. | Enterprise-grade, deep AWS alignment. Less ergonomic than SST. |
|
|
430
|
+
| **AWS CDK** | General-purpose IaC in TypeScript/Python/Java. Not serverless-specific. | Most flexible, steepest learning curve. Foundation for SST. |
|
|
431
|
+
| **Terraform** | Cloud-agnostic IaC. HashiCorp. | Multi-cloud support, large ecosystem. More verbose for serverless than SAM/SST. |
|
|
432
|
+
| **LocalStack** | Local AWS service emulation for development and testing. | Covers 80+ AWS services. Gaps remain in behavioral fidelity. Pro tier for advanced features. |
|
|
433
|
+
| **Architect (arc.codes)** | Lightweight serverless framework. Convention-over-configuration. | Smaller community, clean design. Good for simple projects. |
|
|
434
|
+
|
|
435
|
+
### Observability stack
|
|
436
|
+
|
|
437
|
+
Serverless observability requires specialized tooling because traditional APM agents cannot run inside Lambda (no persistent process to attach to).
|
|
438
|
+
|
|
439
|
+
- **AWS X-Ray:** Native distributed tracing. Free tier generous. Integration with Lambda is automatic but shallow.
|
|
440
|
+
- **Datadog Serverless:** Cold start tracing, enhanced metrics, function-level cost attribution. Industry leader for serverless observability.
|
|
441
|
+
- **Lumigo:** Purpose-built for serverless. Auto-traces without code changes. Visualizes function chains.
|
|
442
|
+
- **Powertools for AWS Lambda:** Open-source library (Python, TypeScript, Java, .NET) providing structured logging, tracing, metrics, and idempotency utilities. Should be the first dependency in every Lambda function.
|
|
443
|
+
|
|
444
|
+
---
|
|
445
|
+
|
|
446
|
+
## Decision Tree
|
|
447
|
+
|
|
448
|
+
Use this decision tree to determine whether serverless is appropriate for your workload:
|
|
449
|
+
|
|
450
|
+
```
|
|
451
|
+
START: What is the workload pattern?
|
|
452
|
+
|
|
|
453
|
+
+-- Event-driven (file uploads, webhooks, queue messages)?
|
|
454
|
+
| |
|
|
455
|
+
| +-- Execution time < 15 minutes?
|
|
456
|
+
| | |
|
|
457
|
+
| | +-- YES --> Serverless is the natural fit.
|
|
458
|
+
| | +-- NO --> Use containers (ECS/Fargate) or batch (AWS Batch).
|
|
459
|
+
| |
|
|
460
|
+
| +-- Traffic is purely event-driven, no steady baseline?
|
|
461
|
+
| +-- YES --> Serverless. Scale-to-zero saves significant cost.
|
|
462
|
+
| +-- NO --> Consider hybrid (containers for baseline, Lambda for spikes).
|
|
463
|
+
|
|
|
464
|
+
+-- API / Request-Response?
|
|
465
|
+
| |
|
|
466
|
+
| +-- Traffic ratio: peak / baseline > 10x?
|
|
467
|
+
| | |
|
|
468
|
+
| | +-- YES --> Serverless. Auto-scaling handles spikes without over-provisioning.
|
|
469
|
+
| | +-- NO --> Traffic is steady. Evaluate cost.
|
|
470
|
+
| |
|
|
471
|
+
| +-- Steady traffic > 10M requests/day?
|
|
472
|
+
| | |
|
|
473
|
+
| | +-- YES --> Cost-compare Lambda vs. Fargate. Containers likely cheaper.
|
|
474
|
+
| | +-- NO --> Serverless is cost-effective.
|
|
475
|
+
| |
|
|
476
|
+
| +-- Latency requirement: p99 < 100ms?
|
|
477
|
+
| | |
|
|
478
|
+
| | +-- YES + JVM runtime --> Containers (cold starts are 1-3s in Java).
|
|
479
|
+
| | +-- YES + lightweight runtime --> Serverless with provisioned concurrency.
|
|
480
|
+
| | +-- NO --> Serverless is fine.
|
|
481
|
+
| |
|
|
482
|
+
| +-- Requires WebSockets or persistent connections?
|
|
483
|
+
| +-- YES --> Containers. Lambda cannot maintain persistent connections.
|
|
484
|
+
| +-- NO --> Serverless is fine.
|
|
485
|
+
|
|
|
486
|
+
+-- Background processing / Batch?
|
|
487
|
+
| |
|
|
488
|
+
| +-- Single task duration < 15 minutes?
|
|
489
|
+
| | +-- YES --> Serverless (Lambda).
|
|
490
|
+
| | +-- NO --> AWS Batch, ECS tasks, or Step Functions with Lambda chunking.
|
|
491
|
+
| |
|
|
492
|
+
| +-- Needs GPU?
|
|
493
|
+
| +-- YES --> Not serverless. Use EC2 GPU instances or SageMaker.
|
|
494
|
+
| +-- NO --> Lambda if within time/memory limits.
|
|
495
|
+
|
|
|
496
|
+
+-- Scheduled / Cron jobs?
|
|
497
|
+
|
|
|
498
|
+
+-- Execution time < 15 minutes?
|
|
499
|
+
+-- YES --> Serverless (EventBridge + Lambda). Near-zero cost.
|
|
500
|
+
+-- NO --> ECS Scheduled Tasks or AWS Batch.
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
**Quick heuristics:**
|
|
504
|
+
|
|
505
|
+
- Spiky traffic (>10x peak/base ratio) --> serverless
|
|
506
|
+
- Steady traffic (>10M req/day) --> cost-compare, likely containers
|
|
507
|
+
- Latency-critical (<100ms p99) + JVM --> containers
|
|
508
|
+
- Event-driven + short-lived --> serverless, always
|
|
509
|
+
- Long-running (>15 min) --> containers, always
|
|
510
|
+
- GPU required --> not serverless
|
|
511
|
+
|
|
512
|
+
---
|
|
513
|
+
|
|
514
|
+
## Implementation Sketch
|
|
515
|
+
|
|
516
|
+
### Basic Lambda function with API Gateway (Python)
|
|
517
|
+
|
|
518
|
+
```python
|
|
519
|
+
# handler.py
|
|
520
|
+
import json
|
|
521
|
+
import os
|
|
522
|
+
import boto3
|
|
523
|
+
from datetime import datetime
|
|
524
|
+
|
|
525
|
+
# INIT phase: runs once per container lifecycle
|
|
526
|
+
dynamodb = boto3.resource('dynamodb')
|
|
527
|
+
table = dynamodb.Table(os.environ['TABLE_NAME'])
|
|
528
|
+
|
|
529
|
+
def create_user(event, context):
|
|
530
|
+
"""POST /users - Create a new user."""
|
|
531
|
+
try:
|
|
532
|
+
body = json.loads(event['body'])
|
|
533
|
+
|
|
534
|
+
# Idempotency: use client-provided ID to prevent duplicates
|
|
535
|
+
user_id = body.get('id') or context.aws_request_id
|
|
536
|
+
|
|
537
|
+
item = {
|
|
538
|
+
'id': user_id,
|
|
539
|
+
'email': body['email'],
|
|
540
|
+
'name': body['name'],
|
|
541
|
+
'created_at': datetime.utcnow().isoformat(),
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
table.put_item(
|
|
545
|
+
Item=item,
|
|
546
|
+
ConditionExpression='attribute_not_exists(id)', # Prevent overwrite
|
|
547
|
+
)
|
|
548
|
+
|
|
549
|
+
return {
|
|
550
|
+
'statusCode': 201,
|
|
551
|
+
'headers': {'Content-Type': 'application/json'},
|
|
552
|
+
'body': json.dumps(item),
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
except dynamodb.meta.client.exceptions.ConditionalCheckFailedException:
|
|
556
|
+
return {
|
|
557
|
+
'statusCode': 409,
|
|
558
|
+
'body': json.dumps({'error': 'User already exists'}),
|
|
559
|
+
}
|
|
560
|
+
except KeyError as e:
|
|
561
|
+
return {
|
|
562
|
+
'statusCode': 400,
|
|
563
|
+
'body': json.dumps({'error': f'Missing required field: {e}'}),
|
|
564
|
+
}
|
|
565
|
+
except Exception as e:
|
|
566
|
+
# Log the full error for debugging, return generic message to client
|
|
567
|
+
print(f'Error creating user: {e}')
|
|
568
|
+
return {
|
|
569
|
+
'statusCode': 500,
|
|
570
|
+
'body': json.dumps({'error': 'Internal server error'}),
|
|
571
|
+
}
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
### S3 event trigger (image processing)
|
|
575
|
+
|
|
576
|
+
```python
|
|
577
|
+
# image_processor.py
|
|
578
|
+
import boto3
|
|
579
|
+
from PIL import Image
|
|
580
|
+
import io
|
|
581
|
+
import os
|
|
582
|
+
|
|
583
|
+
s3 = boto3.client('s3')
|
|
584
|
+
OUTPUT_BUCKET = os.environ['OUTPUT_BUCKET'] # Different bucket to prevent recursive loops
|
|
585
|
+
|
|
586
|
+
def handler(event, context):
|
|
587
|
+
"""Triggered by S3 PutObject on input bucket. Resizes image, writes to output bucket."""
|
|
588
|
+
for record in event['Records']:
|
|
589
|
+
source_bucket = record['s3']['bucket']['name']
|
|
590
|
+
source_key = record['s3']['object']['key']
|
|
591
|
+
|
|
592
|
+
# Guard: skip if not an image
|
|
593
|
+
if not source_key.lower().endswith(('.jpg', '.jpeg', '.png', '.webp')):
|
|
594
|
+
print(f'Skipping non-image file: {source_key}')
|
|
595
|
+
continue
|
|
596
|
+
|
|
597
|
+
# Download original
|
|
598
|
+
response = s3.get_object(Bucket=source_bucket, Key=source_key)
|
|
599
|
+
image_data = response['Body'].read()
|
|
600
|
+
|
|
601
|
+
# Resize
|
|
602
|
+
image = Image.open(io.BytesIO(image_data))
|
|
603
|
+
image.thumbnail((300, 300))
|
|
604
|
+
|
|
605
|
+
# Upload to DIFFERENT bucket (critical: prevents recursive trigger)
|
|
606
|
+
buffer = io.BytesIO()
|
|
607
|
+
image.save(buffer, format='JPEG', quality=85)
|
|
608
|
+
buffer.seek(0)
|
|
609
|
+
|
|
610
|
+
output_key = f'thumbnails/{source_key}'
|
|
611
|
+
s3.put_object(
|
|
612
|
+
Bucket=OUTPUT_BUCKET, # NOT source_bucket
|
|
613
|
+
Key=output_key,
|
|
614
|
+
Body=buffer,
|
|
615
|
+
ContentType='image/jpeg',
|
|
616
|
+
)
|
|
617
|
+
|
|
618
|
+
print(f'Processed {source_key} -> {output_key}')
|
|
619
|
+
```
|
|
620
|
+
|
|
621
|
+
### Infrastructure as Code (serverless.yml)
|
|
622
|
+
|
|
623
|
+
```yaml
|
|
624
|
+
service: user-api
|
|
625
|
+
|
|
626
|
+
frameworkVersion: '3'
|
|
627
|
+
|
|
628
|
+
provider:
|
|
629
|
+
name: aws
|
|
630
|
+
runtime: python3.12
|
|
631
|
+
architecture: arm64 # Graviton: 20% cheaper, faster cold starts
|
|
632
|
+
memorySize: 256
|
|
633
|
+
timeout: 10 # Fail fast, not at 15 minutes
|
|
634
|
+
environment:
|
|
635
|
+
TABLE_NAME: !Ref UsersTable
|
|
636
|
+
OUTPUT_BUCKET: !Ref ThumbnailBucket
|
|
637
|
+
iam:
|
|
638
|
+
role:
|
|
639
|
+
statements:
|
|
640
|
+
- Effect: Allow
|
|
641
|
+
Action:
|
|
642
|
+
- dynamodb:PutItem
|
|
643
|
+
- dynamodb:GetItem
|
|
644
|
+
- dynamodb:Query
|
|
645
|
+
Resource: !GetAtt UsersTable.Arn
|
|
646
|
+
- Effect: Allow
|
|
647
|
+
Action:
|
|
648
|
+
- s3:GetObject
|
|
649
|
+
Resource: arn:aws:s3:::${self:service}-uploads-${sls:stage}/*
|
|
650
|
+
- Effect: Allow
|
|
651
|
+
Action:
|
|
652
|
+
- s3:PutObject
|
|
653
|
+
Resource: arn:aws:s3:::${self:service}-thumbnails-${sls:stage}/*
|
|
654
|
+
|
|
655
|
+
functions:
|
|
656
|
+
createUser:
|
|
657
|
+
handler: handler.create_user
|
|
658
|
+
events:
|
|
659
|
+
- httpApi:
|
|
660
|
+
path: /users
|
|
661
|
+
method: post
|
|
662
|
+
# Reserved concurrency prevents this function from consuming all account capacity
|
|
663
|
+
reservedConcurrency: 100
|
|
664
|
+
|
|
665
|
+
processImage:
|
|
666
|
+
handler: image_processor.handler
|
|
667
|
+
memorySize: 1024 # Image processing needs more memory/CPU
|
|
668
|
+
timeout: 60
|
|
669
|
+
events:
|
|
670
|
+
- s3:
|
|
671
|
+
bucket: ${self:service}-uploads-${sls:stage}
|
|
672
|
+
event: s3:ObjectCreated:*
|
|
673
|
+
# DLQ for failed image processing
|
|
674
|
+
destinations:
|
|
675
|
+
onFailure:
|
|
676
|
+
type: sqs
|
|
677
|
+
arn: !GetAtt ImageProcessingDLQ.Arn
|
|
678
|
+
reservedConcurrency: 50 # Limit to prevent overwhelming downstream services
|
|
679
|
+
|
|
680
|
+
resources:
|
|
681
|
+
Resources:
|
|
682
|
+
UsersTable:
|
|
683
|
+
Type: AWS::DynamoDB::Table
|
|
684
|
+
Properties:
|
|
685
|
+
TableName: ${self:service}-users-${sls:stage}
|
|
686
|
+
BillingMode: PAY_PER_REQUEST # Serverless DynamoDB: scales with traffic
|
|
687
|
+
AttributeDefinitions:
|
|
688
|
+
- AttributeName: id
|
|
689
|
+
AttributeType: S
|
|
690
|
+
KeySchema:
|
|
691
|
+
- AttributeName: id
|
|
692
|
+
KeyType: HASH
|
|
693
|
+
|
|
694
|
+
ThumbnailBucket:
|
|
695
|
+
Type: AWS::S3::Bucket
|
|
696
|
+
Properties:
|
|
697
|
+
BucketName: ${self:service}-thumbnails-${sls:stage}
|
|
698
|
+
|
|
699
|
+
ImageProcessingDLQ:
|
|
700
|
+
Type: AWS::SQS::Queue
|
|
701
|
+
Properties:
|
|
702
|
+
QueueName: ${self:service}-image-dlq-${sls:stage}
|
|
703
|
+
MessageRetentionPeriod: 1209600 # 14 days
|
|
704
|
+
```
|
|
705
|
+
|
|
706
|
+
### SST v3 equivalent (TypeScript)
|
|
707
|
+
|
|
708
|
+
```typescript
|
|
709
|
+
// sst.config.ts
|
|
710
|
+
export default $config({
|
|
711
|
+
app(input) {
|
|
712
|
+
return {
|
|
713
|
+
name: 'user-api',
|
|
714
|
+
removal: input?.stage === 'production' ? 'retain' : 'remove',
|
|
715
|
+
};
|
|
716
|
+
},
|
|
717
|
+
async run() {
|
|
718
|
+
// DynamoDB table
|
|
719
|
+
const table = new sst.aws.Dynamo('UsersTable', {
|
|
720
|
+
fields: { id: 'string' },
|
|
721
|
+
primaryIndex: { hashKey: 'id' },
|
|
722
|
+
});
|
|
723
|
+
|
|
724
|
+
// S3 buckets
|
|
725
|
+
const uploadBucket = new sst.aws.Bucket('Uploads');
|
|
726
|
+
const thumbnailBucket = new sst.aws.Bucket('Thumbnails');
|
|
727
|
+
|
|
728
|
+
// API
|
|
729
|
+
const api = new sst.aws.ApiGatewayV2('Api');
|
|
730
|
+
api.route('POST /users', {
|
|
731
|
+
handler: 'src/handler.createUser',
|
|
732
|
+
link: [table],
|
|
733
|
+
memory: '256 MB',
|
|
734
|
+
timeout: '10 seconds',
|
|
735
|
+
});
|
|
736
|
+
|
|
737
|
+
// S3 event processor
|
|
738
|
+
uploadBucket.subscribe('src/image-processor.handler', {
|
|
739
|
+
link: [thumbnailBucket],
|
|
740
|
+
memory: '1024 MB',
|
|
741
|
+
timeout: '60 seconds',
|
|
742
|
+
});
|
|
743
|
+
|
|
744
|
+
return { api: api.url };
|
|
745
|
+
},
|
|
746
|
+
});
|
|
747
|
+
```
|
|
748
|
+
|
|
749
|
+
---
|
|
750
|
+
|
|
751
|
+
## Cross-References
|
|
752
|
+
|
|
753
|
+
- **[Microservices](../microservices.md)** — Serverless functions are often deployed as part of a microservices architecture. Each function can be a micro-microservice. The operational tradeoffs (distributed tracing, service discovery, failure isolation) apply equally.
|
|
754
|
+
- **[Stateless Design](../../design/stateless-design.md)** — Serverless functions are stateless by definition. Understanding stateless design principles is prerequisite to building effective serverless architectures.
|
|
755
|
+
- **[Twelve-Factor App](../../design/twelve-factor-app.md)** — Serverless naturally enforces several twelve-factor principles: config via environment variables, stateless processes, disposability, and log streams. Understanding where serverless diverges (port binding, concurrency model) prevents architectural mistakes.
|
|
756
|
+
- **[Horizontal vs. Vertical Scaling](../horizontal-vs-vertical.md)** — Serverless is the extreme form of horizontal scaling: every invocation is an independent instance. Understanding horizontal scaling tradeoffs (state management, data partitioning) is essential.
|
|
757
|
+
- **[Event-Driven Architecture](../event-driven.md)** — Serverless is most powerful when combined with event-driven patterns. Events trigger functions; functions emit events. Understanding event schemas, eventual consistency, and event sourcing patterns unlocks the full potential of serverless.
|
|
758
|
+
- **[Modular Monolith](./modular-monolith.md)** — The counterpoint. When serverless complexity exceeds its benefits, consolidation into a modular monolith (as Prime Video demonstrated) can reduce cost by 90% and simplify operations.
|
|
759
|
+
|
|
760
|
+
---
|
|
761
|
+
|
|
762
|
+
## Sources
|
|
763
|
+
|
|
764
|
+
- [Serverless Architecture in 2025 — Devsu](https://devsu.com/blog/serverless-architecture-in-2025-is-it-time-to-go-completely-serverless)
|
|
765
|
+
- [Case Studies: Leading Companies with Serverless — StackFiltered](https://www.stackfiltered.com/blog/case_studies_how_leading_companies_succeed_with_serverless_architectures)
|
|
766
|
+
- [AWS Lambda Cold Start Optimization in 2025 — Zircon.tech](https://zircon.tech/blog/aws-lambda-cold-start-optimization-in-2025-what-actually-works/)
|
|
767
|
+
- [AWS Lambda Cold Starts: When They Matter and What They Cost — EdgeDelta](https://edgedelta.com/company/knowledge-center/aws-lambda-cold-start-cost)
|
|
768
|
+
- [Serverless vs Containers: 2025 Guide to Real-World Economics](https://www.ai-infra-link.com/serverless-vs-containers-a-2025-guide-to-real-world-economics/)
|
|
769
|
+
- [Serverless vs Containers Cost Comparison — Binadox](https://www.binadox.com/blog/serverless-vs-containers-which-is-more-cost%E2%80%91effective-in-the-cloud/)
|
|
770
|
+
- [Amazon Prime Video 90% Cost Reduction — DEV Community](https://dev.to/indika_wimalasuriya/amazon-prime-videos-90-cost-reduction-throuh-moving-to-monolithic-k4a)
|
|
771
|
+
- [6 Lessons from Prime Video Serverless vs Monolith — Network World](https://www.networkworld.com/article/972298/6-lessons-from-the-amazon-prime-video-serverless-vs-monolith-flap.html)
|
|
772
|
+
- [Recursive AWS Lambda Horror Stories — Vantage](https://www.vantage.sh/blog/aws-lambda-avoid-infinite-loops)
|
|
773
|
+
- [AWS Lambda Recursive Loop Detection — AWS Docs](https://docs.aws.amazon.com/lambda/latest/dg/invocation-recursion.html)
|
|
774
|
+
- [Cloudflare Workers vs AWS Lambda — 5ly](https://5ly.co/blog/aws-lambda-vs-cloudflare-workers/)
|
|
775
|
+
- [AWS Lambda vs Cloudflare Workers 2025 — Probir Sarkar](https://blog.probirsarkar.com/aws-lambda-vs-cloudflare-workers-2025-cold-start-pricing-and-performance-comparison-f932f945cf6a)
|
|
776
|
+
- [SST Alternatives in 2026 — Northflank](https://northflank.com/blog/sst-alternatives-serverless-stack)
|
|
777
|
+
- [Serverless Computing in 2025: Trends, Use Cases, Challenges — Synoverge](https://www.synoverge.com/blog/serverless-computing-trends-use-cases-challenges/)
|
|
778
|
+
- [Pitfalls of Scaling on Serverless Platforms — Google Cloud Community](https://medium.com/google-cloud/the-pitfalls-of-scaling-on-serverless-platforms-482ad69d7c37)
|
|
779
|
+
- [AWS Case Studies: Optimizing Enterprise Economics with Serverless](https://docs.aws.amazon.com/whitepapers/latest/optimizing-enterprise-economics-with-serverless/case-studies.html)
|
|
780
|
+
- [Understanding and Remediating Cold Starts — AWS Compute Blog](https://aws.amazon.com/blogs/compute/understanding-and-remediating-cold-starts-an-aws-lambda-perspective/)
|