Simple example of the burst-compute framework. Generates a Mandelbrot Set image in N pieces and stitches them together to demonstrate the power of burst computation in the cloud.
-
You must have the Serverless Framework installed and configured.
-
Ensure you have successfully deployed burst-compute to your AWS account.
-
Create an S3 bucket where the fractal image will be generated.
-
Then deploy the example functions, substituting your region and bucket name:
npm install BUCKET=burst-compute-example npm run sls -- deploy --region us-east-1
This will deploy a launcher function you will use the launch burst computation, along with worker and combiner functions that will be called by the burst-compute framework.
-
Open the deployed burst-compute-example-prod-launcher Lambda function in the AWS console.
-
Create a test event. It can be empty (e.g.
{}
) or include any of the following fields:imageWidth
: the width of the final image in pixelsimageHeight
: the height of the final image in pixelstileWidth
: the width of each tile in pixelstileHeight
: the height of each tile in pixelsbatchSize
: the maximum number of tiles to process seriallynumLevels
: the number of levels in the invoker lambda function treelookAt
: a point in the complex plane to look atzoom
: the width and height of the complex planeiterations
: the number of iterations to performautoIterations
: if true, iterations is calculated automatically based on the size of the imageescapeRadius
: radius of circle on the complex plane used to determine if a point is in the setsuperSamples
: number of times to sample the imagecolorScheme
: the color scheme to use (pickColorHSV1, pickColorHSV2, pickColorHSV3, pickColorGrayscale2)
-
Invoke the function with your test event to launch burst computation
-
Check your bucket for the result under /fractal/final.png
You can also monitor progress by checking the burst-compute state machine in the AWS Step Functions console.
{
"imageWidth": 8000,
"imageHeight": 6000,
"tileWidth": 200,
"tileHeight": 200,
"batchSize": 4,
"numLevels": 2,
"colorScheme": "pickColorHSV2"
}
To deploy to a non-prod environment, specify the stage:
npm run sls -- deploy --stage dev
To run the linter:
npm run sls -- lint
To run the unit tests:
npm run sls -- test
The mandelbrot rendering code is adapted from mandelbrot-js by Christian Larsen, licensed under Apache License 2.0.