30% off every course until Sunday, October 11. Our biggest update yet, and we'd like you to try it. Applied automatically at checkout.

Choose your certification
Copyright (c) 2026 MindMesh Academy. All rights reserved. This content is proprietary and may not be reproduced or distributed without permission.

2.1.1.5. Serverless Compute Design Patterns (Lambda, API Gateway, Step Functions)

2.1.1.5. Serverless Compute Design Patterns (Lambda, API Gateway, Step Functions)

💡 First Principle: Abstracting away server management enables rapid innovation, extreme scalability, and cost-effectiveness by shifting from a provisioned capacity model to a pay-per-execution model.

Scenario: An architect needs to design a backend for a new mobile application. The application will expose a set of RESTful APIs, process user requests, and orchestrate a multi-step workflow for order fulfillment involving several microservices and external integrations. The solution needs to be fully serverless to minimize operational overhead and handle unpredictable loads.

Serverless compute fundamentally shifts operational responsibility to AWS, allowing architects to focus on business logic. This paradigm is ideal for event-driven, highly variable, or batch workloads.

  • "AWS Lambda": The core serverless compute service that runs code in response to events.
    • Design Pattern: Event-driven functions. "Lambda" runs code in response to events (e.g., "S3 object upload", "DynamoDB stream", "API Gateway request").
    • Practical Relevance: Building microservices, data processing pipelines, backend for web/mobile apps, automation tasks. Automatically scales from zero to thousands of concurrent executions.
  • "Amazon API Gateway": A fully managed service for creating, publishing, maintaining, monitoring, and securing APIs at scale.
    • Design Pattern: RESTful APIs for "Lambda", HTTP endpoints, or invoking other AWS services.
    • Practical Relevance: Exposing "Lambda functions" as web endpoints, acting as a facade for backend services, providing authentication/authorization.
  • "AWS Step Functions": A serverless workflow service to orchestrate complex, multi-step processes.
    • Design Pattern: Choreography of "Lambda functions", "ECS tasks", or other AWS services.
    • Practical Relevance: Long-running processes, complex data transformations, coordinating microservices. Manages state, error handling, and retries.
  • Scheduled and infrequent work: An "Amazon EventBridge" schedule (rule or Scheduler) invokes a "Lambda" function on a cron or rate expression with no server left running; one function per task keeps each independently deployable and scalable. An on-demand, rarely used endpoint (for example a report generator) fits "API Gateway" plus "Lambda", which costs nothing while idle, whereas always-on EC2, ECS or EKS capacity is paid for continuously. Lambda is limited to 15 minutes per invocation; use "Fargate" or "AWS Batch" for longer jobs.
  • API Gateway features: Usage plans and API keys meter and throttle per consumer (rate, burst, and daily/monthly quota). Stages provide separate deployments (prod, staging) and stage variables point a stage at different Lambda aliases. Stage caching (TTL per method) serves repeated identical requests without invoking the backend, and "AWS WAF" adds rate-based IP blocking. As a facade (the API Gateway or Backend-for-Frontend pattern) it gives clients one entry point for routing, authentication, throttling and caching, and can aggregate several microservice calls into a single client request, cutting round trips.
  • Lambda tuning: Create SDK and database connections outside the handler so warm invocations reuse them. "Reserved concurrency" caps (and guarantees) a function's concurrency, protecting a downstream database from bursts; "Provisioned Concurrency" pre-initializes environments to remove cold starts. Use retries with exponential backoff and jitter, and a dead-letter queue for failed asynchronous invocations. Memory settings also scale CPU.
Visual: Serverless Architecture for Mobile Backend

⚠️ Common Pitfall: Using a single, monolithic "Lambda function" to perform a complex, multi-step workflow. This creates a "Lambda-lith" that is hard to maintain, debug, and violates the single-responsibility principle. Use "Step Functions" to orchestrate multiple, smaller "Lambda functions" instead.

Key Trade-Offs:
  • Simplicity (Single Lambda) vs. Orchestration (Step Functions): For a simple task, a single "Lambda" is fine. For a complex workflow with multiple steps, error handling, and retries, "Step Functions" provides robustness and visibility at the cost of some initial setup complexity.

Reflection Question: How would you combine "Amazon API Gateway", "AWS Lambda", and "AWS Step Functions" to fulfill these requirements for a fully serverless, highly scalable, and robust mobile backend, specifically addressing the orchestration of the multi-step order fulfillment workflow?

See how it connects
Alvin Varughese
Written byAlvin Varughese
Founder•20 professional certifications