Skip to content

Latest commit

 

History

History

README.md

Sysbench AWS Lambda

A containerized AWS Lambda function that runs CPU benchmarks using sysbench.

Files

  • Dockerfile - Container definition with sysbench installation
  • lambda_function.py - Lambda handler that runs sysbench
  • test_event.json - Sample test event

Local Testing

1. Build the Docker image

docker build -t sysbench-lambda .
docker build -t sysbench-lambda-cpu . -f Dockerfile-cpu

2. Run locally with Lambda Runtime Interface Emulator

docker run -p 9000:8080 sysbench-lambda-cpu

3. Test with curl

In another terminal, invoke the function:

# Basic test
curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" \
  -d '{}'

# Custom parameters
curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" \
  -d '{"threads": 2, "time": 5, "max_prime": 20000}'

Event Parameters

All parameters are optional:

  • threads: Number of threads to use (default: 1)
  • time: Test duration in seconds (default: 10)
  • max_prime: Maximum prime number to calculate (default: 64000)

Deploy to AWS

export ACCOUNT_ID=foo REGION=us-west-1 PLATFORM=amd64 TEST=cpu
./update_func.sh

Sample Output

{
  "statusCode": 200,
  "body": {
    "message": "Sysbench CPU test completed",
    "parameters": {
      "threads": 1,
      "time": 10,
      "max_prime": 10000
    },
    "metrics": {
      "events_per_second": 1234.56,
      "total_time": 10.0,
      "total_events": 12345,
      "latency_ms": {
        "min": 0.80,
        "avg": 0.81,
        "max": 1.23
      }
    }
  }
}