Lesson 5 of 9 Modernization Patterns

Replacing Components with Serverless Building Blocks

This lesson explains how modernisation replaces server-based components one by one with serverless building blocks that remove servers, capacity planning and much operational work.

Learning outcomes

After completing this lesson, you will be able to:

  • Identify serverless replacements for common components.
  • Explain the serverless limits that shape a design.
  • Recognise when serverless is not the cheapest option.

Replacing common components

Most components of a traditional application have a serverless equivalent that removes servers to manage. A web server for static content becomes S3 with CloudFront. An application server for APIs becomes API Gateway with Lambda, or ECS on Fargate for longer-running code. A cron server becomes EventBridge Scheduler invoking Lambda or Fargate tasks, and a workflow engine or batch scripts become Step Functions. A message broker for new applications becomes SQS, SNS or EventBridge. A relational database with variable load becomes Aurora Serverless v2, and a key-value or session store becomes DynamoDB. The following table summarises the replacements.

Traditional componentServerless replacement
Web server for static contentS3 with CloudFront
Application server for APIsAPI Gateway with Lambda, or ECS on Fargate
Cron serverEventBridge Scheduler with Lambda or Fargate tasks
Workflow engine or batch scriptsStep Functions
Message broker for new applicationsSQS, SNS, EventBridge
Relational database with variable loadAurora Serverless v2
Key-value or session storeDynamoDB
Match the pairs

Serverless replacements

Exam skills 4.1.5

Match each self-managed component with its serverless replacement.

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

Limits to design around

Serverless services have limits that shape the design. A Lambda function runs for at most 15 minutes, so longer work belongs in Step Functions or Fargate. Lambda concurrency is limited per account and Region, so reserved concurrency protects critical functions from being starved by others.

Relational databases are a common bottleneck: many functions each opening database connections exhaust the database's connection limit, which RDS Proxy prevents by pooling connections, and the Aurora Data API avoids by using HTTP requests instead. Cold starts add latency to the first request in each new execution environment, which SnapStart or provisioned concurrency reduce for latency-sensitive paths.

When serverless is not the cheapest

Pay-per-use pricing is ideal for variable or low traffic. For workloads with high, steady utilisation around the clock, containers or instances with Savings Plans can cost less. The decision weighs the infrastructure bill against the operational effort that serverless removes.

Worked example

Replacing a cron server and a file-processing server

A monolith's server runs two background duties: a nightly clean-up job under cron, and a loop that polls a directory for uploaded CSV files and loads them into the database. Both keep a server running all day for a few minutes of work. The clean-up job becomes a schedule:

aws scheduler create-schedule --name reviews-cleanup \
  --schedule-expression "cron(0 2 * * ? *)" --schedule-expression-timezone "Europe/London" \
  --flexible-time-window Mode=FLEXIBLE,MaximumWindowInMinutes=30 \
  --target "Arn=$CLEANUP_FN_ARN,RoleArn=$SCHEDULER_ROLE_ARN"

Uploads go to an S3 bucket instead of a directory. An S3 event notification sends each new object to EventBridge, which starts a Step Functions workflow that validates the file, loads it with a Distributed Map over its rows, and notifies the uploader. Lambda functions connect to the database through RDS Proxy, so a burst of uploads does not exhaust its connections. Nothing runs, and nothing is billed, when there is no work.

Check yourself

Which services replace a self-managed message broker in a serverless design?

Show answer

SQS, SNS or EventBridge, which need no servers and scale automatically. Amazon MQ suits applications that must keep existing broker protocols.

Exam Tips

Remember for the exam

  • To replace a cron server with serverless services, use EventBridge Scheduler with Lambda.
  • Serve static websites from S3 through CloudFront.
  • When many Lambda functions connect to RDS, use RDS Proxy.
  • For variable relational load, use Aurora Serverless v2.
  • Work longer than 15 minutes belongs in Step Functions, Fargate or Batch.