A containerized AWS Lambda function that runs CPU benchmarks using sysbench.
Dockerfile- Container definition with sysbench installationlambda_function.py- Lambda handler that runs sysbenchtest_event.json- Sample test event
docker build -t sysbench-lambda .
docker build -t sysbench-lambda-cpu . -f Dockerfile-cpudocker run -p 9000:8080 sysbench-lambda-cpuIn 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}'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)
export ACCOUNT_ID=foo REGION=us-west-1 PLATFORM=amd64 TEST=cpu
./update_func.sh{
"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
}
}
}
}