Designing Architecture for Small-Scale Web Application on AWS

Lambda RDS DynamoDB S3 Serverless Mixed Architecture

In the world of cloud computing, not every application needs to handle millions of users or petabytes of data. Many successful web applications operate at a much smaller scale, serving thousands of users effectively while maintaining cost efficiency. This article explores how to design AWS architectures for small-scale web applications that prioritize simplicity, reliability, and cost-effectiveness – with special attention to maximizing AWS Free Tier benefits.

Understanding the Scale

Before diving into architectural decisions, let's define what we mean by "small-scale":

  • Regular traffic of 1-2 requests per second
  • Peak loads of up to 10 requests per second during busy periods
  • Monthly active user base of up to 10,000
  • Data storage requirements under 100GB
  • Development team of 1-5 people

Suggested Architecture

1. Compute Layer

AWS Lambda combined with API Gateway provides an ideal serverless solution:

  • Lambda functions for API endpoints and business logic
  • API Gateway for RESTful API management
  • Consider AWS Lambda Power Tuning tool for optimal memory configuration
  • Free Tier benefits:
    • 1 million free requests per month
    • 400,000 GB-seconds of compute time per month

Advantages of Lambda over EC2:

  • No idle server costs
  • Automatic scaling
  • Built-in high availability
  • Minimal operational overhead
  • Pay-per-use pricing model

2. Database Layer

If you're looking to deploy a small Django app on AWS with minimal operational overhead, consider our fully serverless architecture that utilizes SQLite on EFS for the database layer. For applications that need a more traditional relational database setup, here are the recommended options:

Amazon RDS with db.t4g.micro instance:

  • MySQL or PostgreSQL options
  • ARM-based processor for cost efficiency
  • Single-AZ deployment to start
  • For critical production applications, consider Multi-AZ deployment for improved availability at a higher cost
  • Enable automated backups with 7-day retention

Amazon DynamoDB:

  • Consider Amazon DynamoDB for use cases such as session storage, real-time leaderboards, or user activity logs due to its low-latency key-value operations

3. Storage Layer

S3 and CloudFront for static content:

  • Amazon S3 Standard for active content
  • Implement S3 lifecycle policies:
    • Move to S3-IA after 30 days
    • Consider Glacier for backups after 90 days
  • CloudFront distribution with:
    • Set maximum TTL for your static content caching
    • Use cache invalidation or content versioning (e.g., appending version numbers to asset URLs) to refresh updated content efficiently
    • Enable Brotli compression
    • Enable HTTP/3

4. Security Layer

Essential security implementation:

  • Assign IAM roles to Lambda functions with permissions restricted to specific S3 buckets or RDS instances
  • Configure Origin Access Control for S3 buckets to restrict access
  • Set up VPC with public and private subnets
  • Configure Security groups using the principle of least privilege
  • Add AWS WAF basic rules for common attacks
  • Enable AWS CloudTrail for audit logging

Cost Analysis with Free Tier

Let's assume that our application needs 20 GB for the database and 80 GB for the media assets. Taking into account the AWS Free Tier, this adds up to:

AWS Lambda & API Gateway

Regular traffic calculation:

  • 1.5 RPS × 3600 seconds × 24 hours × 30 days = 3,888,000 requests/month

Lambda costs:

  • Memory: 1024MB = 1GB
  • Average duration: 150ms = 0.15 seconds
  • GB-seconds = 3,888,000 × 0.15s × 1GB = 583,200 GB-seconds/month
  • Free tier: 1M requests and 400,000 GB-seconds
  • Billable requests: 2,888,000 (3,888,000 - 1M free tier)
  • Billable GB-seconds: 183,200 (583,200 - 400,000 free tier)

Cost calculation:

  • Requests: 2,888,000 × $0.20/million = $0.58
  • Compute: 183,200 GB-seconds × $0.0000166667 = $3.05

Lambda total: $3.63/month

RDS (db.t4g.micro)

  • Single AZ, MySQL
  • 20GB storage
  • Free Tier includes 750 hours/month and 20GB storage

Cost: $0 (covered by Free Tier)

S3 Storage

  • 80GB total storage
  • Estimated 5,000 GET requests/month
  • Estimated 500 PUT requests/month
  • Free Tier: 5GB storage, 20,000 GET, 2,000 PUT
  • Paid storage: 75GB × $0.023/GB = $1.73/month

Cost: $1.73/month

CloudFront

  • Estimated 50GB transfer/month
  • First 1TB is $0.085/GB
  • Free Tier includes 1TB transfer

Cost: $0 (covered by Free Tier)

Total Monthly Cost:

First 12 months (with Free Tier):

  • Lambda: $3.63
  • RDS: $0 (covered by Free Tier)
  • S3: $1.73
  • CloudFront: $0 (covered by Free Tier)

Total: $5.36/month

After Free Tier expires:

  • Lambda: $3.63
  • RDS: $13.82 ($11.52 instance + $2.30 storage)
  • S3: $1.73

Total: $18.18/month

These calculations use US East (N. Virginia) region pricing at the time of this writing. Pricing varies by region. Use the AWS Pricing Calculator to estimate costs for your specific region. Free Tier benefits are subject to change; always check AWS's current pricing and terms.

Monitoring and Maintenance

Key metrics to monitor:

  • Lambda execution duration and memory usage
  • API Gateway latency and error rates
  • Database IOPS and CPU credits
  • CloudFront cache hit ratio
  • Error rates across all services

CloudWatch alarms for:

  • Lambda errors > 1%
  • API Gateway latency > 1 second
  • Database CPU credit balance < 20
  • 5XX error rate > 1%
  • Estimated monthly costs > budget

Scaling Considerations

Built-in scalability features:

  1. Lambda automatic scaling with concurrent execution limits
  2. API Gateway handles thousands of requests with 10,000 RPS soft limit
  3. RDS scaling options:
    • Instance type upgrade
    • Storage autoscaling
    • Read replicas when needed
  4. CloudFront global edge network scaling

Best Practices for Cost Management

  1. Optimize Lambda functions:
    • Set appropriate memory and timeout values
    • Purchase Compute Savings Plans
  2. Implement S3 lifecycle policies
  3. Set up AWS Budgets with alerts
  4. Enable Cost Explorer for spending analysis
  5. Regular architecture reviews

Development Workflow

  1. Use Infrastructure as Code (AWS CloudFormation/SAM)
  2. Implement CI/CD with AWS CodePipeline
  3. Maintain separate environments:
    • Development
    • Staging
    • Production
  4. Use parameter store for configuration

Conclusion

This architecture provides a robust foundation for small-scale web applications while maximizing AWS Free Tier benefits. The use of fully-managed services eliminates server management overhead while maintaining flexibility for future growth. With proper monitoring and optimization, this architecture can efficiently serve thousands of users while keeping costs predictable and manageable.

Regular reviews of CloudWatch metrics, costs, and architecture decisions ensure your application remains efficient as it grows. The first year is particularly cost-effective with AWS Free Tier, and costs remain reasonable afterward due to the pay-per-use model and ARM-based services.

This article is intended for developers and architects building web applications on AWS. These recommendations are opinionated and based on our experience.

Get in Touch

Got thoughts, ideas, suggestions on the subject? We'd love to hear them!

Contact Us