BrainyBeeBrainyBee
ExploreBlogStart Studying
HomeAWS Certified DevOps Engineer - Professional (DOP-C02)Scaling Serverless Architectures: Implementing Scalable API Solutions
Hands-On Lab920 words

Scaling Serverless Architectures: Implementing Scalable API Solutions

Implement solutions that are scalable to meet business requirements

Scaling Serverless Architectures: Implementing Scalable API Solutions

This lab focuses on Task Statement 3.2: Implement solutions that are scalable to meet business requirements from the AWS Certified DevOps Engineer - Professional (DOP-C02) exam. You will build a loosely coupled, serverless architecture using Amazon API Gateway and AWS Lambda, then explore how to configure and monitor scaling behaviors.

[!WARNING] Remember to run the teardown commands at the end of the lab to avoid ongoing charges.

Prerequisites

  • An AWS Account with administrative access.
  • AWS CLI installed and configured with appropriate credentials.
  • Basic familiarity with Python (for the Lambda function code).
  • Terminal/Command line access.

Learning Objectives

  • Deploy a serverless REST API using Amazon API Gateway and AWS Lambda.
  • Configure Lambda Concurrency to manage scaling limits and protect downstream resources.
  • Implement API Gateway Throttling to manage request rates and meet business SLAs.
  • Verify scaling behavior through active testing.

Architecture Overview

Loading Diagram...
Figure 1 — Mermaid diagram

Step-by-Step Instructions

Step 1: Create an IAM Execution Role for Lambda

Before creating the function, we need a role that allows Lambda to write logs to CloudWatch.

bash
# 1. Create the trust policy file echo '{"Version": "2012-10-17","Statement": [{"Effect": "Allow","Principal": {"Service": "lambda.amazonaws.com"},"Action": "sts:AssumeRole"}]}' > trust-policy.json # 2. Create the IAM Role aws iam create-role --role-name brainybee-lab-lambda-role --assume-role-policy-document file://trust-policy.json # 3. Attach the basic execution policy aws iam attach-role-policy --role-name brainybee-lab-lambda-role --policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
▶Console alternative

Navigate to IAM > Roles > Create role. Select Lambda as the service. Add the AWSLambdaBasicExecutionRole managed policy. Name it brainybee-lab-lambda-role.

Step 2: Create the Lambda Function

We will create a simple Python function that simulates a processing delay to observe scaling behavior.

bash
# 1. Create the function code echo 'import json import time def lambda_handler(event, context): time.sleep(0.5) # Simulate work return {"statusCode": 200, "body": json.dumps("Scaling Success!")}' > lambda_function.py # 2. Package the code zip function.zip lambda_function.py # 3. Deploy the function (Replace <ACCOUNT_ID> with your actual ID) aws lambda create-function --function-name brainybee-scaling-func \ --zip-file fileb://function.zip --handler lambda_function.lambda_handler --runtime python3.9 \ --role arn:aws:iam::<YOUR_ACCOUNT_ID>:role/brainybee-lab-lambda-role

Step 3: Create the API Gateway

Now we create a REST API to expose our Lambda function via an HTTP endpoint.

bash
# 1. Create the REST API aws apigateway create-rest-api --name "ScalingLabAPI" # 2. Note the "id" from the output. We will call this <API_ID>. # Get the Root Resource ID aws apigateway get-resources --rest-api-id <API_ID> # 3. Create a resource and method (using Root Resource ID <ROOT_ID>) aws apigateway put-method --rest-api-id <API_ID> --resource-id <ROOT_ID> --http-method GET --authorization-type "NONE" # 4. Set the Lambda integration aws apigateway put-integration --rest-api-id <API_ID> --resource-id <ROOT_ID> --http-method GET --type AWS_PROXY \ --integration-http-method POST --uri arn:aws:apigateway:<YOUR_REGION>:lambda:path/2015-03-31/functions/arn:aws:lambda:<YOUR_REGION>:<YOUR_ACCOUNT_ID>:function:brainybee-scaling-func/invocations

Step 4: Configure Scaling Limits (Reserved Concurrency)

To ensure this function doesn't consume all account-wide concurrency, we will set a limit.

bash
aws lambda put-function-concurrency --function-name brainybee-scaling-func --reserved-concurrent-executions 5

[!NOTE] By setting reserved concurrency to 5, we guarantee this function can always scale to 5 instances, but never more, protecting our backend if this were a database-heavy task.

Checkpoints

  1. Deployment Check: Run aws lambda get-function --function-name brainybee-scaling-func. You should see the configuration and the concurrency limit of 5.
  2. API Check: Use the AWS Console to "Test" the API Gateway method. It should return a 200 OK with "Scaling Success!".
  3. Permissions Check: Ensure you have added the Lambda permission to allow API Gateway to invoke it:
    bash
    aws lambda add-permission --function-name brainybee-scaling-func --statement-id apigateway-test \ --action lambda:InvokeFunction --principal apigateway.amazonaws.com

Concept Review

When implementing scalable solutions, DevOps engineers must balance Throughput (requests per second) against Latency (time per request).

Compiling TikZ diagram…
⏳
Running TeX engine…
This may take a few seconds
Figure 2 — TikZ diagram
FeaturePurpose in ScalingMetric to Watch
Reserved ConcurrencyPrevents one function from starving others.ConcurrentExecutions
Provisioned ConcurrencyEliminates "Cold Starts" for low-latency needs.ProvisionedConcurrencyUtilization
API ThrottlingProtects API from spikes at the entry point.429 Too Many Requests

Troubleshooting

ErrorLikely CauseFix
403 ForbiddenMissing Lambda permissions.Run the add-permission command in the Checkpoints section.
429 Too Many RequestsHit API Gateway or Lambda scaling limits.Increase Reserved Concurrency or check API Stage settings.
504 Gateway TimeoutLambda took longer than 29s (API limit).Optimize Lambda code or use asynchronous patterns.

Stretch Challenge

Implement Provisioned Concurrency: Update the Lambda function to use Provisioned Concurrency of 2. This requires creating a function Alias first. Research how this differs from Reserved Concurrency in terms of "Cold Start" performance.

Cost Estimate

ServiceUsageEstimated Monthly Cost (Free Tier)
AWS Lambda1 Million Requests/mo$0.00 (Free Tier Forever)
API Gateway1 Million Requests/mo$0.00 (12 months free)
CloudWatch Logs5GB Ingestion$0.00 (Free Tier)

Clean-Up / Teardown

[!IMPORTANT] Always delete resources to keep your account clean and avoid unexpected costs.

bash
# 1. Delete the API Gateway aws apigateway delete-rest-api --rest-api-id <API_ID> # 2. Delete the Lambda Function aws lambda delete-function --function-name brainybee-scaling-func # 3. Detach and delete the IAM Role aws iam detach-role-policy --role-name brainybee-lab-lambda-role --policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole aws iam delete-role --role-name brainybee-lab-lambda-role # 4. Remove local files rm lambda_function.py function.zip trust-policy.json
All AWS Certified DevOps Engineer - Professional (DOP-C02) Study Resources

Related Notes

  • Scalable Solutions for Business Requirements: A DevOps Study Guide1,150 words
  • Mastering AWS Alerting and Automated Remediation1,050 words
  • Study Guide: Analyzing Failed Deployments in AWS940 words
  • Incident Analysis: Troubleshooting Failed Processes in AWS1,050 words
  • Mastering AWS Monitoring & Security Analytics: Logs, Metrics, and Findings1,050 words
  • AWS Log Analysis: Athena, CloudWatch Insights, and OpenSearch920 words
  • Analyzing Real-Time Log Streams with Amazon Kinesis Data Streams985 words
  • CloudWatch Anomaly Detection Alarms: Professional Study Guide820 words
  • AWS Application Storage Patterns: EBS, EFS, and S31,054 words
  • Lab: Automating Security Controls and Data Protection with AWS Secrets Manager and Config942 words
  • Master Study Guide: Automating Security Controls & Data Protection (AWS DOP-C02)1,184 words
  • Mastering AWS CloudFormation StackSets: Multi-Account & Multi-Region Orchestration895 words

Ready to study AWS Certified DevOps Engineer - Professional (DOP-C02)?

Practice tests, flashcards, and all study notes — free, no sign-up.

Start Studying

Ready to study AWS Certified DevOps Engineer - Professional (DOP-C02)?

Practice tests, flashcards, and all study notes — free, no sign-up needed.

Start Studying — Free
AWS Certified DevOps Engineer - Professional (DOP-C02) ResourcesExplore All HivesBlogHome

© 2026 BrainyBee. Free AI-powered exam prep.

Loading Diagram...
Flowchart, left to right. Client (curl/Browser) connects to API Gateway. B connects to AWS Lambda ("REST Request"). C connects to CloudWatch Logs.