Labs ICT
⭐ Pro Login

Lambda and Serverless

Running code without managing servers

Lambda and Serverless

AWS Lambda lets you run code without provisioning or managing servers. Upload your code, configure triggers, and Lambda handles everything from scaling to patching. You pay only for the compute time you consume.

How Lambda Works


  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚                LAMBDA WORKFLOW                        β”‚
  β”‚                                                      β”‚
  β”‚  Trigger          Lambda Function       Response     β”‚
  β”‚  β”Œβ”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”      β”‚
  β”‚  β”‚ API │────────▢│  Your Code   │────▢│ JSONβ”‚      β”‚
  β”‚  β”‚Gatewayβ”‚       β”‚  (Node.js,   β”‚     β”‚     β”‚      β”‚
  β”‚  β””β”€β”€β”€β”€β”€β”˜         β”‚   Python,    β”‚     β””β”€β”€β”€β”€β”€β”˜      β”‚
  β”‚                  β”‚   Java, etc) β”‚                    β”‚
  β”‚  β”Œβ”€β”€β”€β”€β”€β”         β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜                    β”‚
  β”‚  β”‚ S3  │────────▢       β”‚                           β”‚
  β”‚  β”‚Eventβ”‚                β”‚  AWS handles:             β”‚
  β”‚  β””β”€β”€β”€β”€β”€β”˜                β”‚  - Server provisioning    β”‚
  β”‚                         β”‚  - Scaling (0 to 1000s)   β”‚
  β”‚  β”Œβ”€β”€β”€β”€β”€β”               β”‚  - Patching               β”‚
  β”‚  β”‚Cloud│────────▢      β”‚  - Monitoring             β”‚
  β”‚  β”‚Watchβ”‚               β”‚  - Logging                β”‚
  β”‚  β””β”€β”€β”€β”€β”€β”˜               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  β”‚                                                      β”‚
  β”‚  Pay only when code runs: $0.20 per 1M requests     β”‚
  β”‚  + compute time ($0.0000166667 per GB-second)       β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Lambda Limits and Features

Memory: 128 MB to 10 GB of memory (proportional CPU).

Timeout: Up to 15 minutes per invocation.

Package size: 50 MB (zipped), 250 MB (unzipped) for direct upload.

Concurrent executions: 1,000 by default (can be increased via support).

Layers: Share common code and dependencies across functions.

Common Lambda Patterns


  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚  Pattern            β”‚  Example               β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚  API Backend        β”‚  API Gateway β†’ Lambda  β”‚
  β”‚                     β”‚  β†’ DynamoDB            β”‚
  β”‚  File Processing    β”‚  S3 upload β†’ Lambda    β”‚
  β”‚                     β”‚  β†’ resize/convert      β”‚
  β”‚  Scheduled Tasks    β”‚  EventBridge β†’ Lambda  β”‚
  β”‚                     β”‚  (cron-like jobs)      β”‚
  β”‚  Data Streaming     β”‚  Kinesis β†’ Lambda      β”‚
  β”‚                     β”‚  β†’ process records     β”‚
  β”‚  Chatbot            β”‚  Lex β†’ Lambda          β”‚
  β”‚                     β”‚  β†’ business logic      β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Lambda Best Practices

Keep functions small and focused. Use environment variables for configuration. Implement error handling with dead-letter queues. Use Lambda Layers for shared dependencies. Monitor with CloudWatch Logs and X-Ray tracing. Test locally with SAM CLI before deploying.

πŸ§ͺ Quick Quiz

Which is a key benefit of serverless computing?