Jonatan Matajonmatum.com
conceptsnotesexperimentsessays
© 2026 Jonatan Mata. All rights reserved.v2.1.1
Concepts

Serverless

Cloud computing model where the provider manages infrastructure automatically, allowing code execution without provisioning or managing servers, paying only for actual usage.

evergreen#serverless#cloud#faas#event-driven#aws#scaling

What it is

Serverless is a cloud execution model where the provider allocates resources dynamically and charges only for compute consumed. It doesn't mean "no servers" — it means the developer doesn't manage them. The provider handles provisioning, scaling, patching, and availability.

Fundamental characteristics

  • No server management: no instances to configure or maintain
  • Automatic scaling: from zero to thousands of instances based on demand
  • Pay per use: charged per invocation/duration, not idle time
  • Event-driven: functions execute in response to events

Serverless services in AWS

ServiceFunction
LambdaFunctions as a Service (FaaS)
API GatewayHTTP/REST/WebSocket APIs
DynamoDBNoSQL database
S3Object storage
Step FunctionsWorkflow orchestration
EventBridgeEvent bus
SQS / SNSMessaging

Common patterns

  • API backend: API Gateway → Lambda → DynamoDB
  • Event processing: S3 upload → Lambda → processing
  • Workflows: Step Functions orchestrating multiple Lambdas
  • Cron jobs: EventBridge schedule → Lambda

Advantages

  • Fast time to market
  • Zero cost when there's no traffic
  • Scaling without intervention
  • Smaller attack surface (no OS to patch)

Limitations

  • Cold starts: latency on first invocation (see analysis below)
  • Maximum duration: Lambda has a 15-minute limit per invocation
  • Memory: maximum 10 GB per function
  • Payload: 6 MB synchronous, 256 KB asynchronous
  • Concurrency: 1,000 concurrent executions by default (can be increased)
  • Vendor lock-in: provider-specific APIs
  • State: functions are stateless by design — state goes in DynamoDB, S3, or ElastiCache

Cold starts

A cold start occurs when Lambda creates a new execution environment. Latency varies significantly by runtime and package size:

RuntimeTypical cold startWith SnapStart/provisioned
Node.js100–300 msN/A
Python150–400 msN/A
Java1–3 s200–400 ms with SnapStart
.NET400–800 ms100–200 ms with Native AOT
Rust/Go10–30 msNot needed

Mitigation strategies:

  • Provisioned concurrency: keeps instances "warm" — eliminates cold starts but has a fixed cost
  • SnapStart (Java): snapshot of the initialized environment, reduces cold start from seconds to milliseconds
  • Minimize dependencies: smaller packages initialize faster
  • Initialization outside the handler: code outside the handler runs once and is reused

Serverless vs. containers

CriteriaServerless (Lambda)Containers (Fargate)
Maximum duration15 minutesNo limit
ScalingAutomatic, per invocationAutomatic, by metrics (slower)
Cold start100 ms – 3 s30–60 s (task provisioning)
Idle cost$0Cost per vCPU/memory while running
High traffic costCan be high (per invocation)More predictable (per hour)
StateStatelessCan maintain in-memory state
NetworkingOptional VPC, slow ENINative VPC, full networking

Use serverless when: variable or unpredictable traffic, short executions (under 15 min), small teams wanting zero ops, event-driven architectures.

Use containers when: long-running processes, need for in-memory state, constant and predictable traffic, complex networking requirements.

Cost modeling

Lambda charges $0.20 per million invocations plus $0.0000166667 per GB-second. For an API with 1 million requests/month, 256 MB memory, and 200 ms average:

  • Invocations: 1M × $0.20 = $0.20
  • Compute: 1M × 0.2s × 0.25 GB × $0.0000166667 = $0.83
  • Total: ~$1.03/month

The same load on Fargate (0.25 vCPU, 0.5 GB, running 24/7): ~$9.10/month. Serverless wins for variable loads. But at 100M requests/month, Lambda costs ~$103 while Fargate stays at ~$9.10 — the crossover point depends on the traffic pattern.

Anti-patterns

  • Monolithic Lambda: one function that does everything — loses granular scaling advantages and increases cold starts
  • Lambda-to-Lambda chains: invoking one Lambda from another directly — use Step Functions or SQS instead
  • Over-orchestration: Step Functions for logic that fits in a single function — adds unnecessary latency and cost
  • Ignoring concurrency limits: without reserved concurrency, one function can consume the entire account quota
  • Functions without timeout: the default timeout is 3 seconds, but unadjusted functions can run for 15 minutes by mistake

Why it matters

Serverless eliminates server management and payment for idle capacity. For workloads with variable traffic — APIs, event processing, scheduled tasks — the pay-per-execution model can dramatically reduce costs while scaling automatically.

References

  • Serverless Architectures — AWS — AWS, 2024. Official serverless services documentation.
  • Serverless Land — AWS, 2024. Patterns, examples, and resources for serverless architectures.
  • Operating Lambda: Performance optimization — AWS Compute Blog, 2022. Detailed cold start analysis and optimization strategies.
  • Lambda concurrency — AWS, 2024. Reserved and provisioned concurrency documentation.
  • Serverless Framework — Serverless Inc, 2024. Multi-cloud framework for serverless applications.

Related content

  • AWS Lambda

    AWS serverless compute service that runs code in response to events without provisioning or managing servers, automatically scaling from zero to thousands of concurrent executions.

  • Infrastructure as Code

    Practice of defining and managing infrastructure through versioned configuration files instead of manual processes. Foundation of modern operations automation.

  • Event-Driven Architecture

    Architectural pattern where components communicate through asynchronous events, enabling decoupled, scalable, and reactive systems.

  • AWS Fargate

    Serverless compute engine for containers that eliminates server management, allowing Docker container execution paying only for consumed resources.

  • AWS Bedrock

    AWS serverless service providing access to foundation models from multiple providers (Anthropic, Meta, Mistral, Amazon) via unified API, without managing ML infrastructure.

  • Cloud Native

    Development approach leveraging cloud advantages: containers, microservices, immutable infrastructure, and declarative automation for scalable and resilient systems.

  • Cost Optimization

    Practices and strategies to minimize cloud spending without sacrificing performance, including right-sizing, reservations, spot instances, and eliminating idle resources.

  • From Prototype to Production: A Serverless Second Brain on AWS

    Architecture design for scaling a personal second brain to a production system with AWS serverless — from the current prototype to specialized use cases in legal, research, and community building.

  • Building a Second Brain in Public

    Chronicle of building a second brain with a knowledge graph, bilingual pipeline, and agent endpoints — in days, not weeks, and what that teaches about the gap between theory and working systems.

  • Terraform AWS Serverless Modules

    Collection of 13 Terraform modules published on the Terraform Registry for deploying serverless architectures on AWS, with 12 examples covering basic ECS to full-stack CRUD with DynamoDB and AgentCore with MCP.

  • Serverless First Presentation

    Slidev presentation on 10 reasons to adopt a serverless-first architecture. Deployed on GitHub Pages.

  • Serverless Second Brain

    Production-ready serverless backend for a personal knowledge graph — DynamoDB, Lambda, Bedrock, MCP, Step Functions. The implementation of the architecture described in the 'From Prototype to Production' essay.

  • Serverless Lab

    Personal lab for serverless architecture experiments: prototypes, patterns, and learnings about event-driven applications on AWS.

  • PR Auto-Approver

    Serverless GitHub App that auto-approves pull requests after CI passes, with optional AI code review via Amazon Bedrock. Five repositories: TypeScript/Probot app, AWS Terraform module (Lambda + API Gateway + Secrets Manager + SQS DLQ), GitHub Terraform module (webhooks), deployment infra, and test repo.

  • Devcontainer Serverless Fullstack Template

    Devcontainer template for serverless fullstack development with Python backend, React frontend, and local AWS services.

  • Progressive Web Apps

    Web applications using modern technologies to deliver native app-like experiences: installable, offline-capable, and with push notifications.

  • Next.js

    React framework for full-stack web applications with Server Components, file-based routing, SSR/SSG, and built-in performance optimizations.

  • Logging Strategies

    Practices for implementing effective logging in distributed systems: structured logging, levels, correlation, and centralized aggregation.

  • Inference Optimization

    Techniques to reduce cost, latency, and resources needed to run language models in production, from quantization to distributed serving.

  • AWS Well-Architected Framework

    AWS framework with six pillars of best practices for designing and operating reliable, secure, efficient, and cost-effective cloud systems.

  • AWS Step Functions

    AWS serverless orchestration service that coordinates multiple services into visual workflows using Amazon States Language (ASL), with built-in error handling, retries, and parallel execution.

  • AWS SQS

    AWS fully managed message queue service that decouples distributed application components, guaranteeing message delivery with unlimited scalability.

  • AWS SNS

    AWS pub/sub messaging service that distributes messages to multiple subscribers simultaneously, enabling fan-out patterns and notifications at scale.

  • AWS SAM

    AWS open-source framework for building serverless applications with simplified CloudFormation syntax, CLI for local development, and integrated deployment.

  • AWS S3

    AWS object storage service with 99.999999999% durability, unlimited scalability, and multiple storage classes for cost optimization.

  • AWS EventBridge

    AWS serverless event bus connecting applications using events, enabling decoupled event-driven architectures with rule-based routing.

  • AWS DynamoDB

    AWS serverless NoSQL database with single-digit millisecond latency at any scale, ideal for applications requiring high performance and automatic scalability.

  • AWS API Gateway

    AWS managed service for creating, publishing, and managing REST, HTTP, and WebSocket APIs that act as entry points to Lambda functions and other backend services.

  • API Gateway Pattern

    Pattern providing a single entry point for multiple microservices, handling routing, authentication, rate limiting, and response aggregation.

Concepts