Lesson 1 of 3 Architecture Patterns

Recognising Reference Architectures for Web, Serverless and Batch

This lesson explains the reference architectures that most architecture questions vary, and why each component is there, so it is easier to see what a scenario is missing and which answer completes it.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe a highly available three-tier web application.
  • Describe a serverless application.
  • Describe a batch processing architecture.

A highly available three-tier web application

A highly available web application is built in tiers, and each tier removes a single point of failure. At the edge, Route 53 resolves the domain and can fail over between endpoints, CloudFront caches content close to users and absorbs traffic spikes, and AWS WAF filters attacks before they reach the application.

The web and application tier runs on EC2 instances in an Auto Scaling group spread across three Availability Zones, behind an Application Load Balancer. The load balancer sends traffic only to healthy instances, and the group replaces failed instances and adds capacity as demand grows. Because any instance may disappear, session state is kept in ElastiCache or DynamoDB rather than on the instances, so a user's next request can be served by any of them.

The data tier uses Aurora with replicas in other Availability Zones, or RDS Multi-AZ, so the database fails over automatically if its primary fails. Static content and uploads are stored in S3, which is durable and scales without limit, and are served through CloudFront. The following table summarises the tiers.

TierComponentsPurpose
EdgeRoute 53, CloudFront, AWS WAFDNS, caching near users, filtering attacks
Web and applicationApplication Load Balancer; EC2 Auto Scaling group across three AZsSpread traffic; replace failed instances; scale with demand
Session stateElastiCache or DynamoDBKeep instances stateless
DataAurora with replicas in other AZs (or RDS Multi-AZ)Durable, highly available relational data
Static content and uploadsAmazon S3Unlimited, durable object storage

The following diagram shows the tiers described above.

A highly available three-tier web application. Route 53, CloudFront and AWS WAF form the edge. An Application Load Balancer sends traffic to an Auto Scaling group spread across three Availability Zones, which keeps session state in ElastiCache or DynamoDB. The data tier is Aurora with replicas in other zones, and static content is stored in S3 and served through CloudFront.
Because no instance holds session state, any instance can serve any request, and losing one zone loses no sessions.
Match the pairs

Three-tier components

Exam skills 2.1.1 · 2.2.2

Match each tier of a highly available web application with its components.

Log in to try this activity Interactive activities are free with an account.

A serverless application

A serverless application is assembled entirely from managed services, so there are no servers to patch or scale. The static front end, such as a single-page application, is stored in S3 and delivered through CloudFront, or hosted with Amplify Hosting. Sign-in is handled by Amazon Cognito, which issues tokens that the API checks. The API is API Gateway invoking Lambda functions, and data is stored in DynamoDB, which scales with the traffic. Background work is passed through SQS or EventBridge to other Lambda functions, and multi-step processes are coordinated by Step Functions. The following table summarises the components.

NeedComponents
Static front endS3 and CloudFront (or Amplify Hosting)
Sign-inAmazon Cognito
APIAPI Gateway with Lambda
DataDynamoDB
Background workSQS or EventBridge with Lambda; Step Functions for workflows

Every component scales automatically and costs nothing when idle, which suits variable traffic and small teams. Its limits (Lambda's 15 minutes, API Gateway's 29-second default integration timeout) push long work into asynchronous patterns.

The following diagram shows how the serverless components connect.

A serverless application. The single-page front end is stored in S3 and delivered through CloudFront. Users sign in with Amazon Cognito, whose tokens API Gateway checks. API Gateway invokes Lambda functions that store data in DynamoDB. Background work passes through SQS or EventBridge to other functions, and Step Functions coordinates multi-step processes.
Long work leaves the request path through the queue or event bus, which keeps API responses within their timeouts.
Match the pairs

Serverless components

Exam skills 2.1.5 · 2.1.1

Match each need in a serverless application with its service.

Log in to try this activity Interactive activities are free with an account.

Batch and data processing

A batch processing architecture separates the arrival of work from its processing, so each part can scale and fail independently. When files arrive in S3, S3 event notifications or EventBridge start processing without any polling. An SQS queue buffers the jobs, so a burst of files does not overwhelm the workers and no job is lost if a worker fails.

The jobs run cheaply on AWS Batch, which manages job queues and launches capacity as needed, or on an Auto Scaling group of Spot Instances that scales with the queue depth; because the queue keeps each job until it is completed, an interrupted Spot Instance only delays the work. Results are stored in S3 and queried with Athena, or loaded into Redshift for heavy analysis. The following table summarises the components.

NeedComponents
Files arrive and trigger processingS3 event notifications or EventBridge
Buffer and distribute jobsSQS
Run jobs cheaplyAWS Batch or an Auto Scaling group on Spot Instances
Store results and query themS3 with Athena, or Redshift for heavy analysis

The following diagram shows the batch pipeline from arrival to results.

A batch processing architecture. Files arriving in S3 trigger processing through event notifications or EventBridge. An SQS queue buffers the jobs, so bursts do not overwhelm the workers and no job is lost. AWS Batch or an Auto Scaling group of Spot Instances processes them, scaling with the queue depth, and results go to S3 for Athena or to Redshift.
The queue decouples arrival from processing, so each side scales and fails independently.
Put in order

A batch pipeline

Exam skills 2.1.1 · 3.2.1

Put the stages of a batch processing architecture in order.

Log in to try this activity Interactive activities are free with an account.
Worked example

Completing a design

A company's web application runs on EC2 instances in an Auto Scaling group behind an ALB in two AZs. Users report being logged out when instances are replaced. What should the architect change?

Comparing with the reference architecture shows what is missing: session state is stored on the instances. Moving sessions to ElastiCache (or DynamoDB) makes the instances stateless, so Auto Scaling can replace them without affecting users. Sticky sessions would only reduce the problem, not solve it.

Check yourself

Where should session data be kept so that any web server can handle any request?

Show answer

Outside the servers, in a shared store such as ElastiCache or DynamoDB, so the web tier is stateless.

Exam Tips

Remember for the exam

  • A highly available web tier is an ALB with an Auto Scaling group across multiple AZs.
  • Keep instances stateless by storing sessions in ElastiCache or DynamoDB.
  • Serverless designs combine S3, CloudFront, Cognito, API Gateway, Lambda and DynamoDB.
  • Batch processing pairs SQS with Spot Instances or AWS Batch for low cost.
  • Compare a scenario with the reference architecture to find the missing piece.