ferroxlabs/wayland/serverless-patterns

Claude Code and agent skill by ferroxlabs/wayland

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Guides expert-level serverless patterns implementation: cloud and architecture decision frameworks, production-ready patterns, and concrete templates for serverless patterns workflows. Use when the user asks about serverless patterns, serverless patterns configuration, or backend best practices for serverless projects. Do NOT use when the user needs a different backend infrastructure capability -- check sibling skills in the backend infrastructure subcategory.

Install

npx vskill@latest install ferroxlabs/wayland/serverless-patterns

SKILL.md

The same SKILL.md was published earlier as ferroxlabs/wayland/serverless-patterns.

Serverless Patterns

When to Use

Use this skill when:

  • User is designing or refactoring a cloud function architecture and needs to choose between event-driven, fan-out, saga, or aggregator patterns
  • User is experiencing cold start latency, timeout cascades, or function chaining bottlenecks and needs targeted remediation patterns
  • User is building a system with functions that need to coordinate state across multiple invocations (orchestration vs. choreography decision)
  • User asks how to handle idempotency, partial failures, or retry storms in a distributed serverless system
  • User wants to implement a backend-for-frontend (BFF) pattern, strangler fig migration, or event sourcing architecture using serverless compute
  • User is choosing between synchronous API gateway invocation, asynchronous queue-triggered functions, and stream-processing triggers for a specific workload
  • User needs to design a multi-region active-active or active-passive serverless deployment with failover guarantees
  • User is hitting AWS Lambda concurrency limits, GCP Cloud Functions quota walls, or Azure Functions plan restrictions and needs architectural remediation

Do NOT use this skill when:

  • User needs container orchestration decisions (Kubernetes, ECS task definitions) -- use the container-orchestration skill
  • User needs API gateway configuration specifics (rate limiting, authentication, routing rules) without the broader serverless pattern context -- use the api-gateway skill
  • User is asking about serverless databases (DynamoDB table design, Firestore data modeling) as a primary concern -- use the serverless-data-modeling skill
  • User needs CI/CD pipeline design for deploying serverless functions -- use the deployment-pipelines skill
  • User is asking about infrastructure-as-code tooling choices (CDK vs. Terraform vs. SAM) without an architectural pattern question -- use the iac-tooling skill
  • User needs general cloud cost optimization without a specific pattern focus -- use the cloud-cost-optimization skill
  • User is asking about WebSocket or long-polling server implementations where serverless is fundamentally inappropriate for the workload

Process

1. Characterize the Workload Profile

Before recommending any pattern, extract the following signal from the user's description:

  • Invocation trigger type -- HTTP request (synchronous, latency-sensitive), event stream (Kinesis, Kafka, Pub/Sub -- throughput-sensitive), queue message (SQS, Cloud Tasks -- at-least-once delivery), scheduled (cron-like), or storage event (S3 put, GCS object finalize)
  • Execution duration distribution -- p50/p99 execution times matter. Functions exceeding 15 minutes on AWS Lambda require Step Functions or Fargate offload. GCP Cloud Functions gen2 supports up to 60 minutes; Azure Durable Functions have no hard timeout on activity functions
  • Concurrency profile -- bursty (marketing email blast triggers 50,000 simultaneous invocations) vs. steady-state (1,000 req/sec continuous). Bursty workloads require concurrency throttle design to protect downstream dependencies
  • Statefulness requirement -- stateless (pure transformation, no coordination needed), ephemeral state (within a single invocation), or durable state (must survive function restarts -- requires external state store or orchestrator)
  • Failure tolerance -- can the operation be retried without side effects (idempotent), or does a partial execution require compensation logic (saga pattern)?
  • Payload size -- Lambda hard limit is 6 MB synchronous / 256 KB async; SQS message limit is 256 KB. Payloads exceeding limits require the claim-check pattern (store payload in S3, pass reference)
2. Apply the Pattern Selection Decision Tree

Work through this decision framework in order:

  • Is coordination of multiple functions required?
  • YES and you need visibility/retries/timeouts per step -- use Orchestration (Step Functions / Durable Functions / Cloud Workflows)
  • YES but you want loose coupling and independent deployability -- use Choreography via event bus (EventBridge, Cloud Pub/Sub, Azure Event Grid)
  • NO -- proceed to trigger type
  • What is the trigger type?
  • HTTP/API -- evaluate BFF pattern (one function per client type) vs. monolithic function (single Express/Fastify app packaged as Lambda) vs. fine-grained single-purpose functions
  • Queue/stream -- evaluate competing consumers pattern (parallel function instances draining a queue) vs. fan-out/fan-in (splitter + worker pool + aggregator)
  • Schedule -- evaluate scheduled job pattern with idempotency guard vs. offset schedule pattern to avoid thundering herd at :00 minutes
  • Does the operation mutate external state?
  • YES -- apply transactional outbox pattern or saga pattern depending on whether you can tolerate eventual consistency
  • NO -- stateless transformation is safe with simple retry logic
  • Is cold start latency acceptable?
  • p99 cold start budget > 500ms -- standard provisioned execution, optimize package size
  • p99 cold start budget < 200ms -- use provisioned concurrency (AWS), minimum instances (GCP gen2), or always-warm (Azure Premium plan); also evaluate moving to edge runtime (Cloudflare Workers, Lambda@Edge) for sub-50ms cold starts
  • Real-time gaming, HFT, or sub-10ms requirements -- serverless is architecturally inappropriate; recommend containerized always-on service
3. Design the Idempotency Strategy

Every serverless function that mutates state must have an explicit idempotency strategy because at-least-once delivery is the default for all major cloud event systems:

  • Idempotency key sources -- use messageId (SQS), eventId (EventBridge), messageId (Pub/Sub), or a client-supplied X-Idempotency-Key header for HTTP triggers
  • Idempotency store options -- DynamoDB conditional writes (PutItem with attribute_not_exists(pk) condition) for AWS; Firestore transactions for GCP; Redis with NX SET for cross-cloud or self-managed
  • TTL on idempotency records -- set TTL equal to the maximum retry window plus a 2x safety buffer. SQS standard queues retry for up to 4 days; set idempotency record TTL to 10 days
  • Idempotency at the boundary only -- apply idempotency checks at the outermost function entry point, not deep inside business logic. This prevents double-processing even if internal sub-calls fail and the whole function is retried
  • Conditional idempotency -- read operations do not need idempotency guards. Only writes, sends, and external API calls require protection
4. Implement the Chosen Pattern with Production Hardening

For each selected pattern, apply these production requirements:

  • Dead Letter Queues (DLQs) -- every async-triggered function MUST have a DLQ configured. Lambda async invocations retry twice by default before dropping the event permanently without a DLQ. Set maximum receive count on SQS source queues to 3-5 before routing to DLQ
  • Timeout alignment -- function timeout must be shorter than the visibility timeout of the source queue (SQS default 30 seconds) or the ack deadline (Pub/Sub default 10 seconds). Lambda timeout + 5 second buffer = SQS visibility timeout minimum. If function timeout is 60 seconds, set SQS visibility timeout to at least 65 seconds
  • Batch size tuning -- SQS Lambda trigger batch size of 10 is a reasonable default for most workloads. For high-throughput streams (Kinesis), start at batch size 100 with bisect-on-error enabled so a single bad record doesn't block the shard
  • Power tuning -- Lambda power tuning is a quantitative exercise. Use the AWS Lambda Power Tuning open-source tool (or equivalent for GCP/Azure) to test 256 MB, 512 MB, 1024 MB, and 1769 MB (1 vCPU allocation point) configurations. CPU-bound functions frequently achieve 50% lower cost at 1769 MB due to the speed improvement outweighing the higher memory price
  • Structured logging -- emit JSON logs with requestId, correlationId, functionName, functionVersion, duration, and business-specific fields. Avoid string concatenation logs that cannot be queried in CloudWatch Insights, GCP Log Explorer, or Azure Monitor
  • Distributed tracing -- instrument with OpenTelemetry or the native SDK (X-Ray, Cloud Trace, Application Insights). Propagate trace context across async boundaries by embedding traceId and spanId in event payloads and message attributes
5. Design the Error Handling and Retry Topology

Serverless error handling is topological -- the retry behavior depends on where in the invocation chain the error occurs:

  • Synchronous (API Gateway -> Lambda) -- no automatic retry. The caller receives the error response directly. Implement circuit breaker at the API Gateway or client level using exponential backoff with jitter: delay = min(cap, base * 2^attempt) + random_jitter
  • Asynchronous (SNS/EventBridge -> Lambda) -- Lambda retries twice with 1-minute and 2-minute delays. After 3 total attempts, the event goes to the DLQ if configured, or is silently dropped. Always configure a DLQ on the Lambda function's event source mapping AND on the SNS topic/EventBridge rule
  • Queue-triggered (SQS -> Lambda) -- Lambda does NOT retry on its own. SQS re-queues the message after the visibility timeout expires. Configure maxReceiveCount on the source queue (3-5 is appropriate for most cases). After exceeding this count, SQS routes to the DLQ automatically
  • Partial batch failures -- for SQS batch processing, return batchItemFailures from the Lambda handler with the specific itemIdentifier values that failed. This prevents the entire batch from being re-processed when only some records failed. Without this, a single bad record causes all 10 batch items to retry
  • Poison message handling -- implement a DLQ processor function that parses failed messages, extracts the failure reason from the ApproximateFirstReceiveTimestamp and ApproximateReceiveCount attributes, emits a metric/alert, and either quarantines or requeues with manual review flag
6. Validate Performance, Cost, and Operational Characteristics

Before finalizing the design, quantify these dimensions:

  • Cold start impact -- measure cold start frequency as a percentage of total invocations. If cold starts exceed 5% of invocations for a user-facing function, apply provisioned concurrency or minimum instances. Calculate the cost of provisioned concurrency vs. the revenue impact of cold start latency degradation
  • Cost modeling -- serverless cost = (invocation count per-invocation price) + (GB-seconds GB-second price) + (data transfer). For AWS Lambda: $0.20 per 1M requests + $0.0000166667 per GB-second. A function running 100ms at 512MB costs $0.0000000083 per invocation. At 10M invocations/day, monthly cost is ~$2,490 for compute alone. Model at realistic p50 duration, not worst-case
  • Concurrency limit planning -- AWS default regional Lambda concurrency is 1,000 (soft limit, increasable). Reserve 200 for critical functions, distribute the remainder. A single SQS queue with batch size 10 processing at maximum can consume 100 concurrent Lambda invocations per second. Calculate peak concurrency requirements and request limit increases before launching
  • Observability baseline -- establish these four signals before going to production: (1) invocation count, (2) error rate %, (3) duration p50/p95/p99, (4) throttle count. Set alarms on error rate > 1% and throttle count > 0 for user-facing functions
7. Document the Architecture Decision

Produce a concise ADR (Architecture Decision Record) capturing:

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
608
Repository forks
113
7-day trend score
37

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/ferroxlabs/wayland/serverless-patterns/badge)](https://verified-skill.com/skills/ferroxlabs/wayland/serverless-patterns)

Something wrong with this skill or its page? Tell us.