Serverless technologies and patterns (for example, Lambda, Fargate)

Task Statement 3.2: Design high-performing and elastic compute solutions.

📘AWS Certified Solutions Architect – (SAA-C03)


Serverless Technologies and Patterns in AWS

Serverless computing is a cloud computing model where you don’t manage the servers. AWS automatically handles server provisioning, scaling, patching, and maintenance. You only focus on your code and services.

Key AWS serverless technologies include:

  1. AWS Lambda
  2. AWS Fargate
  3. Supporting services (for patterns): API Gateway, Step Functions, EventBridge, S3, DynamoDB, etc.

1. AWS Lambda

What it is:
AWS Lambda lets you run your code without managing servers. You only pay for the compute time your code uses, in milliseconds.

Key points for the exam:

  • Event-driven: Lambda functions run in response to events like:
    • A file uploaded to Amazon S3
    • A new message in Amazon SQS
    • An HTTP request via API Gateway
    • A scheduled time using EventBridge
  • Stateless: Each Lambda execution is independent. The function doesn’t retain data between invocations.
  • Scaling: Lambda automatically scales based on the number of events. If 1000 events arrive simultaneously, AWS creates 1000 separate executions.
  • Supported languages: Python, Node.js, Java, Go, C#, Ruby, PowerShell.
  • Pricing: Pay only for the number of requests and the duration of execution. No charge for idle time.

IT Example:

  • You have a website upload portal. Every time a user uploads a file to S3, a Lambda function automatically resizes images and stores thumbnails in another S3 bucket. No server management is required, and scaling happens automatically if 10 users or 10,000 users upload at the same time.

2. AWS Fargate

What it is:
AWS Fargate is a serverless compute engine for containers. It works with Amazon ECS and Amazon EKS, letting you run containers without managing the underlying EC2 instances.

Key points for the exam:

  • Serverless for containers: Unlike EC2, you don’t choose instance types or manage scaling. Fargate handles all infrastructure.
  • Task-based pricing: You pay for CPU and memory allocated to your containers per second.
  • Scaling: Fargate automatically provisions resources based on your container needs.
  • Use case difference with Lambda:
    • Lambda is best for short-lived, event-driven workloads (<15 minutes).
    • Fargate is suitable for long-running or containerized workloads (microservices, batch jobs).

IT Example:

  • You run a data processing pipeline in containers. Each container reads messages from an SQS queue, processes data, and writes results to DynamoDB. Fargate launches containers as needed and shuts them down when processing is done.

3. Serverless Patterns

Serverless applications often use patterns combining multiple AWS services. These patterns are exam-relevant.

a. Event-Driven Pattern

  • Components react to events rather than running continuously.
  • Key services: Lambda, EventBridge, S3, SQS, SNS
  • IT Example:
    • S3 triggers Lambda when a new log file arrives.
    • Lambda parses the log and sends alerts via SNS if errors are found.

b. Backend-for-Frontend Pattern

  • A serverless API tailored to each client interface.
  • Key services: API Gateway + Lambda
  • IT Example:
    • Mobile app calls API Gateway.
    • API Gateway invokes Lambda to fetch user data from DynamoDB.
    • Only the required data is returned, improving efficiency.

c. Fan-Out/Fan-In Pattern

  • One event triggers multiple parallel Lambda functions (fan-out) and then combines results (fan-in).
  • Key services: Lambda, SNS, Step Functions
  • IT Example:
    • Uploading a large dataset triggers multiple Lambda functions to process chunks in parallel.
    • Step Functions combine results and store them in a central database.

d. Queue-Based Pattern

  • Decouples components using a message queue for asynchronous processing.
  • Key services: SQS + Lambda
  • IT Example:
    • Orders from a web app are placed in SQS.
    • Lambda functions pick up messages from the queue and update inventory or send emails.

e. Microservices Pattern

  • Build services independently using serverless components.
  • Key services: Lambda, Fargate, DynamoDB, API Gateway
  • IT Example:
    • A shopping cart service uses Lambda + DynamoDB.
    • Payment service uses Fargate containers.
    • Each service scales independently.

4. Advantages of Serverless

  1. No server management – AWS handles all infrastructure.
  2. Automatic scaling – Code scales based on demand.
  3. Cost-efficient – Pay only for what you use.
  4. Quick deployment – Faster development and iteration.
  5. Integration with AWS services – Works seamlessly with S3, DynamoDB, SNS, SQS, EventBridge, and more.

5. Limitations

  1. Lambda execution timeout – Max 15 minutes per invocation.
  2. Cold starts – Initial invocation may have a slight delay.
  3. State management – Must use external services like DynamoDB or S3 for persistence.
  4. Resource limits – CPU, memory, and disk space limits per function or container.

6. Exam Tips

  • Remember key differences:
    • Lambda = short-lived, event-driven, stateless
    • Fargate = containerized, long-running workloads
  • Focus on serverless patterns: event-driven, queue-based, fan-out/fan-in, microservices, backend-for-frontend.
  • Integration is crucial: Know how Lambda works with S3, DynamoDB, SQS, SNS, API Gateway.
  • Billing is usage-based, not per server.

Summary Table for Easy Recall

Feature / ServiceAWS LambdaAWS Fargate
Managed servers
Containers
Execution time<15 minLong-running
Event-drivenPartial (via ECS/EKS integration)
PricingPay per request & durationPay per CPU & memory
ScalingAutomatic per eventAutomatic per task
Buy Me a Coffee