loading image
Back to glossary

AWS Lambda

Amazon's serverless compute service that runs code in response to events without requiring server management. Billed per millisecond of execution.

Updated on January 23, 2026

AWS Lambda is Amazon Web Services' flagship serverless computing service. It executes backend code without provisioning or managing servers, billing only for actual compute time consumed. This approach revolutionizes cloud development by eliminating infrastructure constraints.

Fundamentals

  • On-demand execution: code activates automatically in response to triggers (HTTP events, S3 changes, SQS messages)
  • Automatic scalability: Lambda instantly adjusts capacity from 0 to thousands of concurrent executions
  • Precise billing model: pay per millisecond of execution and GB of allocated memory, with 1 million free requests monthly
  • Multi-language support: Node.js, Python, Java, Go, C#, Ruby, and custom runtimes via Lambda layers

Benefits

  • Dramatic operational cost reduction: no idle servers, billing based on actual usage
  • Zero infrastructure management: AWS handles patches, availability, scaling and monitoring
  • Accelerated time-to-market: focus on business logic without DevOps considerations
  • Native resilience: isolated executions, automatic retry, CloudWatch integration for observability
  • Seamless integration: direct connection with 200+ AWS services (DynamoDB, S3, API Gateway, EventBridge)

Practical Example

Here's a Node.js Lambda function that automatically processes images uploaded to S3 by generating thumbnails:

image-processor.ts
import { S3Event } from 'aws-lambda';
import sharp from 'sharp';
import { S3Client, GetObjectCommand, PutObjectCommand } from '@aws-sdk/client-s3';

const s3Client = new S3Client({});

export const handler = async (event: S3Event) => {
  for (const record of event.Records) {
    const bucket = record.s3.bucket.name;
    const key = decodeURIComponent(record.s3.object.key.replace(/\+/g, ' '));
    
    // Fetch original image
    const getCommand = new GetObjectCommand({ Bucket: bucket, Key: key });
    const { Body } = await s3Client.send(getCommand);
    const imageBuffer = await streamToBuffer(Body);
    
    // Generate thumbnail (300x300)
    const thumbnail = await sharp(imageBuffer)
      .resize(300, 300, { fit: 'cover' })
      .toBuffer();
    
    // Save to /thumbnails folder
    const thumbnailKey = `thumbnails/${key}`;
    const putCommand = new PutObjectCommand({
      Bucket: bucket,
      Key: thumbnailKey,
      Body: thumbnail,
      ContentType: 'image/jpeg'
    });
    
    await s3Client.send(putCommand);
    console.log(`Thumbnail created: ${thumbnailKey}`);
  }
};

const streamToBuffer = async (stream: any): Promise<Buffer> => {
  const chunks: Uint8Array[] = [];
  for await (const chunk of stream) chunks.push(chunk);
  return Buffer.concat(chunks);
};

Implementation

  1. Define the trigger: select the event source (API Gateway, S3, CloudWatch Events, SQS, etc.)
  2. Choose runtime: select language and version compatible with your dependencies
  3. Configure resources: allocate memory (128 MB to 10 GB) and timeout (max 15 minutes for standard Lambda)
  4. Manage permissions: create IAM role with minimal required rights (principle of least privilege)
  5. Deploy code: via AWS console, CLI, SAM, Serverless Framework or Infrastructure as Code (Terraform, CDK)
  6. Monitor: enable X-Ray for distributed tracing and analyze CloudWatch metrics (duration, errors, throttling)

Performance Optimization

Enable provisioned concurrency for critical functions to eliminate cold starts. Use Lambda Layers to share common dependencies across functions and reduce deployment package size. For intensive workloads, consider Lambda with ARM64 architecture (Graviton2) for better performance-to-cost ratio.

  • AWS SAM (Serverless Application Model): specialized IaC framework for serverless applications
  • Serverless Framework: multi-cloud tool to deploy and manage Lambda functions
  • AWS Step Functions: orchestration of complex Lambda workflows with state management
  • CloudWatch Logs Insights: advanced querying and analysis of Lambda logs
  • Lambda Power Tuning: open-source tool to automatically optimize cost/performance ratio
  • LocalStack: local AWS ecosystem emulation for development and testing

AWS Lambda radically transforms cloud computing economics by perfectly aligning costs with delivered value. By eliminating infrastructure management, technical teams can concentrate 100% of their energy on product innovation. For startups and enterprises alike, it's an ROI accelerator that enables rapid hypothesis testing without upfront infrastructure investment.

Related terms

Themoneyisalreadyonthetable.

In 1 hour, discover exactly how much you're losing and how to recover it.

Web development, automation & AI agency

contact@peaklab.fr
Newsletter

Get our tech and business tips delivered straight to your inbox.

Follow us

© PeakLab 2025