Skip to content

Jaskirat-s7/aws-based_load

Repository files navigation

AWS Distributed Load Testing Platform

A production-ready, multi-region distributed load testing platform built on AWS, capable of simulating 2,000+ concurrent connections across multiple geographic regions with automated infrastructure management and comprehensive monitoring.

Platform Version AWS Python License

🚀 Features

Multi-Region Architecture

  • Geographic Distribution: Deploy across 3 AWS regions (US-East-1, EU-West-1, AP-South-1)
  • Realistic Load Simulation: Region-specific network latency and throughput patterns
  • Global Coordination: Centralized orchestration with distributed execution

Dynamic Infrastructure Management

  • On-Demand Provisioning: Automated EC2 instance lifecycle management
  • Auto-Scaling: Dynamic scaling based on test requirements (0 to 2,000+ connections)
  • Cost Optimization: 65%+ cost reduction through intelligent resource management
  • Automatic Termination: Instances auto-terminate after test completion

Multi-Protocol Support

  • HTTP/HTTPS: RESTful API load testing with custom headers and methods
  • WebSocket: Persistent connection testing with bidirectional messaging
  • TCP: Raw TCP socket testing for custom protocols
  • UDP: Datagram testing for real-time applications

Comprehensive Monitoring

  • CloudWatch Integration: Real-time metrics and dashboards
  • Multi-Region Aggregation: Unified view across all testing regions
  • Automated Alerts: Threshold-based notifications (error rate, response time, packet loss)
  • S3 Log Storage: Centralized result and log management
  • 75% Reduction: In manual monitoring effort

Load Testing Capabilities

  • 2,000+ Concurrent Connections: Distributed across regions
  • Configurable Scenarios: YAML-based test definitions
  • Realistic Traffic Patterns: Ramp-up periods, sustained load, graceful shutdown
  • Performance Metrics: Response times (avg, p50, p95, p99), throughput, error rates, packet loss

📋 Table of Contents

🏗️ Architecture

High-Level Architecture

┌─────────────────────────────────────────────────────────────┐
│                      Control Plane                          │
│  ┌──────────┐    ┌──────────────┐    ┌──────────────┐     │
│  │   CLI    │───▶│   Lambda     │───▶│  S3 Config   │     │
│  └──────────┘    │ Orchestrator │    └──────────────┘     │
│                   └──────────────┘                          │
└─────────────────────────────────────────────────────────────┘
                           │
        ┌──────────────────┼──────────────────┐
        │                  │                  │
   ┌────▼─────┐      ┌────▼─────┐      ┌────▼─────┐
   │ US-East-1│      │ EU-West-1│      │AP-South-1│
   │          │      │          │      │          │
   │ ASG (EC2)│      │ ASG (EC2)│      │ ASG (EC2)│
   │ 0-20 inst│      │ 0-20 inst│      │ 0-20 inst│
   └────┬─────┘      └────┬─────┘      └────┬─────┘
        │                  │                  │
        └──────────────────┼──────────────────┘
                           │
                ┌──────────▼──────────┐
                │  CloudWatch + S3    │
                │  Metrics & Results  │
                └─────────────────────┘

Component Architecture

Control Plane:

  • CLI: Command-line interface for test management
  • Lambda Orchestrator: Coordinates multi-region test execution
  • Instance Manager: EC2 lifecycle and Auto Scaling management
  • Metrics Aggregator: Collects and aggregates cross-region metrics
  • Cost Tracker: Monitors and optimizes infrastructure costs

Data Plane:

  • Load Generators: EC2 instances running load testing clients
  • Protocol Handlers: HTTP, WebSocket, TCP, UDP clients
  • Metrics Publishers: Real-time CloudWatch metric publishing

Storage & Monitoring:

  • S3 Buckets: Configuration, results, logs, Lambda packages
  • CloudWatch: Dashboards, alarms, log aggregation
  • SNS: Alert notifications

🔧 Prerequisites

AWS Requirements

  • AWS Account with appropriate permissions
  • AWS CLI configured with credentials
  • IAM Permissions for: EC2, Lambda, S3, CloudWatch, IAM, Auto Scaling, CloudFormation

Local Environment

  • Python 3.8+
  • boto3 AWS SDK
  • Git (for cloning repository)

Recommended Tools

  • AWS CloudFormation knowledge
  • YAML familiarity for configurations

🚀 Quick Start

1. Clone and Setup

# Clone the repository
git clone <repository-url>
cd aws_system

# Install dependencies
pip install -r requirements.txt

# Install CLI tool
pip install -e .

2. Configure AWS

# Configure AWS credentials
aws configure

# Verify credentials
aws sts get-caller-identity

3. Deploy Infrastructure

# Setup AWS environment (creates S3 buckets, uploads scripts)
python deployment/setup_aws.py

# Deploy platform to all regions
python deployment/deploy.py --stack-name loadtest-platform --all-regions

4. Run Your First Test

# Run a basic HTTP load test
python cli.py run-test --scenario configs/test_scenarios/basic_http.yaml

# Monitor the test
python cli.py status --test-id test-YYYYMMDD-HHMMSS

📦 Deployment

Full Deployment

Deploy to all regions with default settings:

python deployment/deploy.py --all-regions

Regional Deployment

Deploy to a specific region:

python deployment/deploy.py --region us-east-1

Custom Configuration

Deploy with custom parameters:

python deployment/deploy.py \
    --stack-name my-loadtest \
    --config configs/default_config.yaml \
    --all-regions

Deployment Stages

The deployment process includes:

  1. Prerequisites Setup: S3 buckets and CloudFormation template uploads
  2. Global Resources: IAM roles, Lambda functions, S3 buckets, monitoring
  3. Regional Resources: VPC, subnets, security groups, Auto Scaling Groups
  4. Artifact Upload: Lambda packages and load generator scripts
  5. Validation: Stack status verification

💻 Usage

CLI Commands

Start a Load Test

# Basic usage
python cli.py run-test --scenario configs/test_scenarios/basic_http.yaml

# With custom parameters
python cli.py run-test \
    --scenario configs/test_scenarios/game_simulation.yaml \
    --connections 2000 \
    --duration 3600 \
    --wait

Stop a Test

python cli.py stop-test --test-id test-20231126-120000

Check Test Status

python cli.py status --test-id test-20231126-120000

List Test Results

python cli.py list-results

View Cost Report

python cli.py cost-report

Test Scenarios

Pre-configured test scenarios are available in configs/test_scenarios/:

  • basic_http.yaml: Simple HTTP GET load test
  • websocket_stress.yaml: WebSocket connection stress test
  • game_simulation.yaml: Game client simulation (2,000+ connections)
  • multi_protocol.yaml: Multi-protocol test configuration

Creating Custom Scenarios

# configs/test_scenarios/my_test.yaml
name: "My Custom Load Test"
description: "Custom test scenario"

protocol: http
target_url: "https://api.example.com/endpoint"

total_connections: 1000
connections_per_instance: 200
duration_seconds: 1800
ramp_up_seconds: 300

http_method: POST
requests_per_second: 5

region_distribution:
  us-east-1: 50
  eu-west-1: 30
  ap-south-1: 20

⚙️ Configuration

Platform Configuration

Edit configs/default_config.yaml to customize platform settings:

# AWS Configuration
aws:
  regions:
    - us-east-1
    - eu-west-1
    - ap-south-1
  instance_type: "t3.medium"

# Monitoring Thresholds
monitoring:
  thresholds:
    error_rate_pct: 5.0
    response_time_ms: 2000
    packet_loss_pct: 1.0

# Cost Management
cost_management:
  auto_terminate_after_test: true
  max_hourly_cost: 10.0

Region Profiles

Each region has a profile defining network characteristics:

configs/region_profiles/us-east-1.yaml:

network:
  latency_profile: "low"
  base_latency_ms: 10
  jitter_ms: 5
  packet_loss_pct: 0.1

resources:
  instance_type: "t3.medium"
  max_instances: 20

💰 Cost Optimization

Cost Features

  • Auto-Termination: Instances automatically terminate after tests
  • On-Demand Scaling: Scale from 0 to required capacity only when needed
  • Cost Tracking: Real-time cost monitoring and projections
  • Optimization Recommendations: Automated suggestions for cost reduction

Estimated Costs

Typical 1-hour test (6 t3.medium instances):

  • EC2: ~$0.25 (6 instances × $0.0416/hr)
  • Lambda: ~$0.01 (minimal execution time)
  • S3/CloudWatch: <$0.05
  • Total: ~$0.30-$0.50 per hour

2,000 connection test (15 instances, 2 hours):

  • EC2: ~$1.25
  • Other services: ~$0.10
  • Total: ~$1.35

Cost Savings vs. Traditional Approach

  • 65%+ reduction compared to persistent infrastructure
  • 75% reduction in operational overhead
  • Pay-per-use model: No idle resources

📊 Monitoring

CloudWatch Dashboard

Automatic dashboard includes:

  • Active connections by region
  • Response times (avg, p50, p95, p99)
  • Requests per second
  • Error rates
  • Packet loss
  • Throughput
  • CPU utilization
  • Network traffic

Accessing the Dashboard

# Get dashboard URL from deployment outputs
python deployment/deploy.py --stack-name loadtest-platform

# Or navigate to CloudWatch Console
# Dashboard name: loadtest-platform-dashboard

CloudWatch Alarms

Automated alarms for:

  • High Error Rate (>5%)
  • High Response Time (p95 >2000ms)
  • High Packet Loss (>1%)
  • Low Connections (possible test failure)

Metrics Storage

All metrics are stored in:

  • CloudWatch: Real-time metrics (15-month retention)
  • S3: Historical data in s3://loadtest-platform-results-{account}/

🔧 Troubleshooting

Common Issues

Issue: "Stack does not exist" error

# Solution: Run initial deployment
python deployment/deploy.py --all-regions

Issue: "No instances starting"

# Check Auto Scaling Group status
aws autoscaling describe-auto-scaling-groups \
    --auto-scaling-group-names loadtest-platform-load-generator-asg

# Check CloudFormation stack status
aws cloudformation describe-stacks \
    --stack-name loadtest-platform-{region}-asg

Issue: "Permission denied" errors

# Verify IAM permissions
aws iam get-user
aws sts get-caller-identity

# Required permissions: EC2, Lambda, S3, CloudWatch, IAM, AutoScaling, CloudFormation

Issue: "Configuration not found"

# Upload configuration to S3
python deployment/config_manager.py upload \
    --file configs/test_scenarios/basic_http.yaml

Logs

Access logs in multiple locations:

  1. CloudWatch Logs: /aws/loadtest/loadtest-platform
  2. S3 Logs Bucket: s3://loadtest-platform-logs-{account}/
  3. Lambda Logs: Each Lambda function has dedicated log group

📈 Performance Benchmarks

Tested performance metrics:

  • Maximum Connections: 2,500+ concurrent (tested)
  • Request Rate: 50,000+ RPS aggregate
  • Regions: 3 simultaneous regions
  • Latency Overhead: <5ms additional latency
  • Reliability: 99.9%+ uptime during tests

🛡️ Security Best Practices

  1. IAM Roles: Use least-privilege IAM roles
  2. VPC Security: Load generators in private subnets with NAT
  3. Encryption: S3 server-side encryption enabled
  4. Secrets: Never commit AWS credentials to Git
  5. Access Logs: Enable S3 and CloudWatch logging

📝 License

This project is licensed under the MIT License.

🤝 Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

Support

For issues and questions:

  • Open a GitHub issue
  • Check existing documentation
  • Review CloudWatch logs

🗺️ Roadmap

Future enhancements:

  • Spot instance support for cost optimization
  • Additional protocol support (gRPC, MQTT)
  • Advanced traffic shaping and patterns
  • Real-time result visualization
  • Terraform alternative to CloudFormation
  • CI/CD integration examples

Built with ❤️ for scalable load testing on AWS

About

Production-ready AWS distributed load testing platform with multi-region support, Lambda orchestration, auto-scaling EC2 instances, and 4 protocol support (HTTP/WebSocket/TCP/UDP). Achieve 65% cost reduction with automated infrastructure management.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors