Theme

Interactive diagram · architecture

Design a system that scales to millions of users on AWS

AWS scaling architecture flow A client uses DNS, a CDN, a load balancer, web servers, queues, caches, SQL replicas, NoSQL, and object storage as the service scales. Design Scaling AWS Diagram after donnemartin/system-design-primer · CC BY 4.0 resolvestatic filesHTTPS ClientDNSCDN1 · Front door Load BalancerWeb Server2 · Spread the load WorkerServiceQueue4 · Async work WorkerServiceQueue6 · Scale async work Memory Cache3 · Read scaling NoSQLSQL WriteMaster–SlaveSQL ReadReplicasObjectStoreSHARDINGCustomers A–MSQLCustomers N–ZSQLFEDERATIONCustomersSQLProductsSQL5 · Store & scale data
✕

1 · Entry

DNS maps the domain to the public endpoint. A CDN moves static content closer to the client.

✕

2 · Distribute requests

A load balancer distributes traffic across web servers so the web tier can scale horizontally.

✕

3 · Serve read-heavy traffic

Read requests use memory first, then SQL read replicas, reducing load on the write master.

✕

4 · Run work asynchronously

A queue decouples slow jobs from the request path. A worker pulls and completes them later.

✕

5 · Store and scale data

SQL replication, object storage, sharding, and federation help the data tier grow.

✕

6 · Scale async capacity

Another queue and worker service add capacity for background jobs.

✕

Client

Step 1 · Entry

What it is

The user or program making a read or write request.

Its job here

It resolves the service name with DNS or requests static content from the CDN. Dynamic traffic goes to the Load Balancer.

Trade-off

The service must secure incoming HTTP, HTTPS, and SSH access.

In the primer

Communication › HTTP →

✕

DNS

Step 1 · Entry

What it is

DNS maps a domain to a public IP address.

Its job here

It receives the client lookup and directs the client to the public endpoint. The client can then reach the CDN or Load Balancer.

Examples

  • Route 53

Trade-off

DNS lets a domain point to a new IP for failover.

In the primer

Domain name system › Disadvantages →

✕

CDN

Step 1 · Entry

What it is

A content delivery network serves static and some dynamic content closer to users.

Its job here

It receives static requests from the Client and serves files from Object Store. This reduces load and latency for the Web Server.

Examples

  • CloudFront

Trade-off

Static content moved to a CDN increases system complexity.

In the primer

Content delivery network › Disadvantages →

✕

Load Balancer

Step 2 · Distribute requests

What it is

A component that distributes incoming traffic across servers.

Its job here

It receives client traffic and hands requests to Web Server instances. It can terminate SSL before traffic reaches the servers.

Examples

  • ELB
  • HAProxy

Trade-off

Horizontal scaling adds components and operational complexity.

In the primer

Load balancer › Horizontal scaling →

✕

Web Server

Step 2 · Distribute requests

What it is

The public compute tier that receives and processes requests.

Its job here

It receives work from the Load Balancer. It reads through Memory Cache, sends writes to the SQL Write Master–Slave, or adds background jobs to Queue.

Examples

  • EC2

Trade-off

Vertical scaling can become expensive and has no redundancy or failover.

In the primer

Reverse proxy › Load balancer vs reverse proxy →

✕

Worker Service

Step 4 · Run work asynchronously

What it is

A worker that runs jobs outside the request path.

Its job here

It pulls a job from Queue and creates a thumbnail or updates a Database. It can then store the thumbnail in Object Store.

Examples

  • EC2
  • Lambda

Trade-off

Queues add delays and complexity.

In the primer

Asynchronism › Task queues →

✕

NoSQL

Step 4 · Run work asynchronously

What it is

A database used for appropriate data outside the relational store.

Its job here

Worker Service can update this database after pulling a Queue job. It holds data that does not need the SQL write path.

Examples

  • DynamoDB

Trade-off

Choose SQL or NoSQL based on the data and access needs.

In the primer

Database › NoSQL →

✕

Memory Cache

Step 3 · Serve read-heavy traffic

What it is

An in-memory store for frequently accessed content and session data.

Its job here

Web Server checks it first for reads. On a miss, the request continues to SQL Read Replicas.

Examples

  • ElastiCache

Trade-off

Try the MySQL cache before adding a memory cache.

In the primer

Cache › Application caching →

✕

SQL Write Master–Slave

Step 5 · Store and scale data

What it is

The relational database that accepts writes and replicates them to slaves.

Its job here

Web Server sends writes here. Changes replicate to SQL Read Replicas for read traffic.

Examples

  • MySQL
  • RDS

Trade-off

One write master can become a bottleneck as writes increase.

In the primer

Database › Master-slave replication →

✕

Object Store

Step 5 · Store and scale data

What it is

Storage for static files separate from the web server.

Its job here

CDN serves files from it. Web Server and Worker Service can store user files and thumbnails here.

Examples

  • S3

Trade-off

Separate storage requires Web Server changes and adds complexity.

✕

Sharding

Step 5 · Store and scale data

What it is

A pattern that splits one data set across databases.

Its job here

Customers A–M and Customers N–Z hold different ranges. The application selects the right shard for each operation.

Trade-off

Sharding is an additional SQL scaling pattern to consider as data grows.

In the primer

Database › Sharding →

✕

Federation

Step 5 · Store and scale data

What it is

A pattern that splits databases by function.

Its job here

Customers SQL and Products SQL keep different functions separate. The application selects the database for the operation.

Trade-off

Federation is an additional SQL scaling pattern to consider as data grows.

In the primer

Database › Federation →

←/→ step · Space play/pause · R replay · Home/End jump

Detail · follows playback, or click any box or step to pin it

Click any box for an explanation, or use Next or Play to walk through the six steps.

1 · Entry

DNS maps the domain and a CDN can serve static content.

The client reaches a public endpoint before it sends a request.

2 · Distribute requests

A load balancer distributes traffic across Web Server instances.

The web tier can then scale horizontally and avoid a single point of failure.

3 · Serve read-heavy traffic

Memory Cache handles frequent reads before SQL Read Replicas.

This lowers pressure on the SQL write master.

4 · Run work asynchronously

Queue holds background work until Worker Service can process it.

This separates slow jobs, such as thumbnail creation, from the request path.

5 · Store and scale data

SQL replication, Object Store, sharding, and federation support the growing data tier.

The data architecture evolves as storage, reads, and writes become bottlenecks.

6 · Scale async capacity

A second queue and worker service increase background-job capacity.

Long-running work can scale separately from request processing.