Skip to content
Tutorials Center
My learning

Topics

Lesson 57 of 70 ยท Architecture

Common Architecture Patterns

Five AWS patterns you will meet again and again: three-tier web app, serverless API, event-driven pipeline, static site with CDN and a data lake, with diagrams.

Most AWS systems are variations on a handful of shapes. A web shop, an internal dashboard and a mobile backend look different on the surface, yet underneath they often reuse the same arrangement of load balancer, compute, storage and queue. Knowing the shapes lets you start a design from a proven layout instead of a blank page, and lets you read other teams' diagrams quickly.

This lesson walks through five patterns: the three-tier web app, the serverless API, the event-driven pipeline, the static site behind a CDN and the data lake. For each one you will see when it fits, what it costs you and where it breaks. The real services cannot run on this site, so the diagrams are read-only. The two Python stand-ins let you trace a request through each pattern and see why a data lake is organised the way it is. The latency numbers in the tracer are invented for teaching; they are not measurements of real AWS services.

How to choose a pattern

Ask four questions before you draw anything:

  1. Who calls it, and how often? Humans in a browser, other services, or a stream of events?
  2. How spiky is the load? Steady traffic suits servers you size. Rare or very bursty traffic suits pay-per-use services.
  3. What must be consistent? A relational database gives you transactions and joins. A key-value store gives you scale and predictable latency.
  4. What can you operate? Every server you run is a server you patch, scale and monitor.

The Well-Architected Framework gives names to these trade-offs. The patterns below are the common answers.

Pattern 1: the three-tier web app

The classic layout separates presentation, application and data. Users reach a load balancer in public subnets. The load balancer forwards to application servers in private subnets. The application servers talk to a database in even more private subnets. Spread every tier over at least two Availability Zones.

flowchart LR
    U["Users"] --> R53["Route 53"]
    R53 --> ALB["Application Load Balancer<br/>public subnets"]
    ALB --> A1["EC2 app server<br/>AZ a"]
    ALB --> A2["EC2 app server<br/>AZ b"]
    A1 --> C["ElastiCache"]
    A2 --> C
    A1 --> DB[("RDS primary<br/>AZ a")]
    A2 --> DB
    DB -. "synchronous standby" .-> DBS[("RDS standby<br/>AZ b")]

Three tiers across two Availability Zones: the load balancer is the only public entry, the database is reachable only from the app tier.

Strengths: it works with almost any existing framework, it is easy to reason about and a relational database gives you transactions. Weaknesses: you pay for idle capacity, you patch the servers and the database is the hardest tier to scale beyond one writer. Typical tools are an Auto Scaling group for the app tier, an Application Load Balancer in front, and RDS Multi-AZ behind. A cache in front of the database absorbs repeated reads (ElastiCache). The project Three-Tier Web App builds this end to end.

Pattern 2: the serverless API

Here nobody runs a server. API Gateway receives the HTTPS request, Lambda runs your code for the duration of the request and DynamoDB stores the data. You pay per request and per millisecond of execution, and capacity scales from zero to thousands of concurrent calls without configuration.

flowchart LR
    U["Client"] --> APIGW["API Gateway"]
    APIGW --> AUTH["Authorizer<br/>(Cognito or Lambda)"]
    APIGW --> L["Lambda function"]
    L --> D[("DynamoDB table")]
    L --> S3["S3 bucket<br/>(large payloads)"]

A serverless API: every box is a managed service, and each scales independently.

Strengths: no idle cost, little operations work and built-in high availability across Availability Zones. Weaknesses: cold starts add latency to the first request on a new execution environment, the 15-minute Lambda limit rules out long jobs, and DynamoDB demands that you design around access patterns rather than ad hoc queries. See API Gateway and Function URLs and the project Serverless REST API.

Pattern 3: the event-driven pipeline

Instead of one component calling the next and waiting, producers publish events and consumers react at their own pace. A queue between the stages absorbs bursts, retries failed work and isolates failures. This is the pattern behind image processing, order handling, log ingestion and most "do this in the background" features.

flowchart LR
    P["Upload to S3"] --> Q["SQS queue"]
    Q --> W["Lambda worker"]
    W --> D[("DynamoDB<br/>results")]
    Q -. "after N failed receives" .-> DLQ["Dead-letter queue"]
    W --> SNS["SNS topic<br/>(notify others)"]
    SNS --> M["Email"]
    SNS --> N["Another queue"]

A producer, a buffer, a worker, a store and a dead-letter queue for work that keeps failing.

The trade-off is that the system is eventually consistent and harder to trace. A request no longer has one call stack, so you need correlation ids, X-Ray or logs and a plan for duplicates, because most AWS queues deliver at least once. Workers must be idempotent: processing the same message twice must be harmless. SQS, SNS and Fan-Out and EventBridge and Step Functions cover the building blocks, and Event-Driven Image Pipeline puts them to work.

Pattern 4: the static site with a CDN

If the page does not change per user, you do not need a server at all. Put the files in a private S3 bucket and let CloudFront serve them from edge locations close to the reader. HTTPS comes from an ACM certificate, the domain from Route 53. Dynamic bits (a contact form, a comment box) call a small serverless API from JavaScript in the browser.

flowchart LR
    U["Reader"] --> CF["CloudFront edge"]
    CF -- "cache hit" --> U
    CF -- "cache miss" --> S3["S3 bucket<br/>(private, via OAC)"]
    U -. "forms, search" .-> API["Serverless API"]

Hits are answered at the edge; only misses travel to the bucket.

This is the cheapest, fastest and most resilient pattern on the list, and it has almost nothing to attack. Its limit is personalisation: anything that depends on who is asking must come from an API or from edge code. See CloudFront CDN and Static Websites and S3 Events.

Pattern 5: the data lake

A data lake stores raw and refined data as files in S3 and lets many engines read them: Athena for SQL, Glue for catalogs and transforms, EMR or Redshift Spectrum for heavy jobs. Storage is cheap and separate from compute, so you pay for queries only when you run them.

flowchart LR
    SRC["Apps, logs, databases"] --> RAW["S3 raw zone"]
    RAW --> ETL["Glue jobs"]
    ETL --> CUR["S3 curated zone<br/>(Parquet, partitioned)"]
    CUR --> ATH["Athena SQL"]
    CUR --> BI["BI dashboards"]
    CAT["Glue Data Catalog"] -. "schemas" .-> ATH

Raw data lands first; curated, columnar and partitioned copies feed the query engines.

Two habits make a lake affordable: store analytics data in a columnar format such as Parquet, and partition the keys by the columns people filter on (year=2026/month=03/). A query that filters on those columns only reads matching prefixes. The second stand-in below shows the effect.

Stand-in 1: trace a request through each pattern

The tracer below models each pattern as a list of hops. Every hop has a name, a description and an invented latency. It prints a timeline, so you can compare where time goes: servers and databases for the three-tier app, a possible cold start for Lambda, and a cache hit versus a miss for the CDN.

Python Request-flow tracer for three patterns

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The invented numbers are not the point; the shape is. In the three-tier app the database round trip is the biggest variable, which is why caching matters. In the serverless API the cold start dwarfs everything else, which is why latency-sensitive paths use provisioned concurrency or keep initialisation light. For the static site, nearly all requests are cheap hits, and even a miss only happens once per edge location per object lifetime.

Stand-in 2: why data lakes use partitions

Here a pretend S3 bucket holds sales files, one per half month, partitioned by year and month. The helper counts how many objects and bytes a query would read with and without partition pruning. Athena's real pricing is per terabyte scanned, which is exactly why this matters.

Python Partition pruning in a pretend data lake

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The real services add more: a Glue Data Catalog stores the partition list so Athena does not have to list S3, and columnar files let the engine read only the requested columns inside each file. The emulator shows only the first saving.

Combining patterns

Real systems mix these shapes. A shop might serve its front end as a static site, call a serverless API for the catalogue, run checkout as a three-tier service because it needs transactions, push order events through a queue to fulfilment workers, and stream clickstream data into a lake. Choose per component rather than per company: a pattern is a tool, not an identity.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which pattern has no idle server cost and scales from zero by itself?

    API Gateway, Lambda and DynamoDB bill per request or per use, so an idle API costs almost nothing and capacity follows demand.
  2. 2. Why do event-driven workers need to be idempotent?

    At-least-once delivery plus retries means the same message may be processed again, so the work must have the same result the second time.
  3. 3. What is the main benefit of partitioning data lake keys by year and month?

    Partition pruning limits how many objects an engine such as Athena reads, which lowers both query time and cost.
  4. 4. A blog has no per-user content. Which pattern fits best?

    Content that is the same for everyone can be served from edge caches with no servers to run, which is cheapest and most resilient.

Summary

  • Pick a pattern by asking who calls the system, how spiky the load is, what must be consistent and what you can operate.
  • A three-tier app suits relational, transactional workloads; it costs idle capacity and patching.
  • A serverless API pays per use and scales from zero; watch cold starts and design DynamoDB around access patterns.
  • Event-driven pipelines buffer work with queues; expect at-least-once delivery and make workers idempotent.
  • Static sites on S3 and CloudFront are the cheapest and fastest option when content is the same for everyone.
  • Data lakes keep columnar, partitioned files in S3 so engines read only what a query needs.

Next: Migration and Hybrid Cloud.