Serverless

From williamzujkowski/standards · View interactive version

Serverless is an AI agent skill from the GitHub repository williamzujkowski/standards. Benefits:

How to use this skill

Skill file

Serverless Computing

Level 1: Quick Reference

Serverless Benefits and Tradeoffs

Benefits:

Tradeoffs:

Common Serverless Patterns

1. API Backend (HTTP Trigger)

Client → API Gateway → Lambda → Database
- RESTful APIs, GraphQL endpoints
- Authentication/authorization at gateway
- Response caching, throttling, API keys

2. Event-Driven Processing (Event Trigger)

S3 Upload → Lambda → Process File → Store Result
SQS Queue → Lambda → Transform Data → Publish Event
DynamoDB Stream → Lambda → Aggregate Metrics

3. Scheduled Tasks (Cron Trigger)

EventBridge Rule (cron) → Lambda → Cleanup/Report/Backup
- Data aggregation (hourly, daily)
- Automated backups and archival
- Health checks and monitoring

4. Stream Processing

Kinesis/Kafka → Lambda → Real-time Analytics → Dashboard
- Log processing and filtering
- Clickstream analysis
- IoT data ingestion

Essential Serverless Checklist

Architecture:

Cold Start Optimization:

Timeouts and Concurrency:

Security:

Observability:

Cost Optimization:


Level 2:

📚 Full Examples: See REFERENCE.md for complete code samples, detailed configurations, and production-ready implementations.

Implementation Guide

AWS Lambda Fundamentals

Runtime Lifecycle:

  1. INIT Phase (cold start):
  1. INVOKE Phase:
  1. SHUTDOWN Phase:

Lambda Handler Pattern:

See REFERENCE.md for complete implementation.

Lambda Layers:

See REFERENCE.md for complete implementation.

Deployment Packages:

Multi-Cloud Comparison:

| Feature | AWS Lambda | Google Cloud Functions | Azure Functions |

|---------|-----------|----------------------|-----------------|

| Max Duration | 15 minutes | 60 minutes (2nd gen) | 10 minutes (Consumption) |

| Memory | 128 MB - 10 GB | 128 MB - 32 GB | 128 MB - 14 GB |

| Cold Start | 100-500ms (Python/Node) | 200-800ms | 150-600ms |

| Concurrency | 1000 default (soft limit) | 1000 per region | 200 per instance |

| Pricing | $0.20/1M requests + $0.0000166667/GB-s | $0.40/1M + $0.0000025/GB-s | $0.20/1M + $0.000016/GB-s |

| Triggers | 20+ (S3, DynamoDB, SQS, API Gateway) | 10+ (HTTP, Pub/Sub, Storage) | 15+ (HTTP, Queue, Blob) |

Serverless Frameworks

1. AWS SAM (Serverless Application Model):

See REFERENCE.md for complete implementation.

2. Serverless Framework:

See REFERENCE.md for complete implementation.

3. AWS CDK (Cloud Development Kit):

See REFERENCE.md for complete implementation.

Event Sources and Triggers

1. API Gateway (HTTP/REST):

See REFERENCE.md for complete implementation.

2. S3 Events:

See REFERENCE.md for complete implementation.

3. SQS (Queue):

See REFERENCE.md for complete implementation.

4. EventBridge (Scheduled/Custom):

See REFERENCE.md for complete implementation.

5. DynamoDB Streams:

See REFERENCE.md for complete implementation.

Cold Start Optimization

Understanding Cold Starts:

Optimization Techniques:

1. Provisioned Concurrency:

See REFERENCE.md for complete implementation.

2. Minimize Package Size:

See REFERENCE.md for complete implementation.

3. Lazy Loading:

See REFERENCE.md for complete implementation.

4. Connection Pooling:

See REFERENCE.md for complete implementation.

5. Choose Fast Runtimes:

Cold Start Benchmarks (512 MB):
- Go: 100-150ms
- Rust: 120-180ms
- Python 3.11: 200-300ms
- Node.js 20: 250-350ms
- Java 17: 1-2s (use Snapstart for sub-200ms)
- .NET 7: 500-800ms

6. Lambda SnapStart (Java):

See REFERENCE.md for complete implementation.

State Management

Ephemeral Storage (Local):

See REFERENCE.md for complete implementation.

DynamoDB (Key-Value):

See REFERENCE.md for complete implementation.

S3 (Large Objects):

See REFERENCE.md for complete implementation.

ElastiCache (Distributed Cache):

See REFERENCE.md for complete implementation.

Step Functions (Workflow State):

See REFERENCE.md for complete implementation.

Observability and Monitoring

Structured Logging:

See REFERENCE.md for complete implementation.

X-Ray Tracing:

See REFERENCE.md for complete implementation.

Custom CloudWatch Metrics:

See REFERENCE.md for complete implementation.

CloudWatch Alarms:

See REFERENCE.md for complete implementation.

Security Best Practices

IAM Roles and Permissions:

See REFERENCE.md for complete implementation.

Secrets Management:

See REFERENCE.md for complete implementation.

VPC Configuration:

See REFERENCE.md for complete implementation.

Input Validation:

See REFERENCE.md for complete implementation.

Testing Strategies

Unit Tests:

See REFERENCE.md for complete implementation.

Integration Tests:

See REFERENCE.md for complete implementation.

Local Testing (SAM CLI):

See REFERENCE.md for complete implementation.

Cost Optimization

Memory Sizing:

See REFERENCE.md for complete implementation.

ARM (Graviton2) Migration:

See REFERENCE.md for complete implementation.

Monitoring Costs:

See REFERENCE.md for complete implementation.

Cleanup and Governance:

See REFERENCE.md for complete implementation.

Examples

Basic Usage

See REFERENCE.md for complete implementation.

Advanced Usage

// TODO: Add advanced example for serverless
// This example shows production-ready patterns

Integration Example

// TODO: Add integration example showing how serverless
// works with other systems and services

See examples/serverless/ for complete working examples.

Integration Points

This skill integrates with:

Upstream Dependencies

Downstream Consumers

Related Skills

Common Integration Patterns

  1. Development Workflow: How this skill fits into daily development
  2. Production Deployment: Integration with production systems
  3. Monitoring & Alerting: Observability integration points

Common Pitfalls

Pitfall 1: Insufficient Testing

Problem: Not testing edge cases and error conditions leads to production bugs

Solution: Implement comprehensive test coverage including:

Prevention: Enforce minimum code coverage (80%+) in CI/CD pipeline

Pitfall 2: Hardcoded Configuration

Problem: Hardcoding values makes applications inflexible and environment-dependent

Solution: Use environment variables and configuration management:

Prevention: Use tools like dotenv, config validators, and secret scanners

Pitfall 3: Ignoring Security Best Practices

Problem: Security vulnerabilities from not following established security patterns

Solution: Follow security guidelines:

Prevention: Use security linters, SAST tools, and regular dependency updates

Best Practices:


Level 3: Deep Dive Resources

Official Documentation

Books and Courses

Tools and Libraries

Community Resources

Bundled Resources

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.