Simple application for demonstrating the features of Amazon CodeGuru Profiler.
The results of this app are available to play with in the AWS console. There is no need to run the code, if you just want to see the results.
- Sign into the AWS console
- Head to CodeGuru Profiler and check out the demo app
The application does some basic image processing, with some CPU-heavy operations alongside some IO-heavy operations.
It consists chiefly of two components which run in parallel, the task publisher and the image processor.
CodeGuru Profiler runs inside the application, in the same way any real application would use it. It collects and reports profiling data about the application, ready to be viewed in the AWS console.
Checks the S3 bucket for available images, and submits the name of some of these images to the SQS queue.
Polls SQS for names of images to process. Processing an image involves downloading it from S3, applying some image transforms (e.g. converting to monochrome), and uploading the result back to S3.
Make sure you have installed the latest version of AWS CLI.
Setup the required components by running the following aws
commands:
- Create two profiling groups in CodeGuru Profiler, named
DemoApplication-WithIssues
andDemoApplication-WithoutIssues
- Create an SQS queue
- Create an S3 bucket
- Install Maven (to build and run the code).
- Create/use an IAM role with permissions to access SQS, S3 and CodeGuru Profiler
aws configure # Set up your AWS credentials and region as usual
aws codeguruprofiler create-profiling-group --profiling-group-name DemoApplication-WithIssues
aws codeguruprofiler create-profiling-group --profiling-group-name DemoApplication-WithoutIssues
aws s3 mb s3://demo-application-test-bucket-1092734-REPLACE-ME
aws sqs create-queue --queue-name DemoApplicationQueue
The demo application can be run in two modes: with-issues
and without-issues
. Thus, you can compare how an
optimized version of the application compares to one with performance issues.
- To run the
with-issues
version, use the following instructions. Remember to replaceYOUR-ACCOUNT-ID
,YOUR-AWS-REGION
andYOUR-BUCKET-REPLACE-ME
as appropriate.
# These need to be set according to your setup:
export DEMO_APP_SQS_URL=https://sqs.YOUR-AWS-REGION.amazonaws.com/YOUR-ACCOUNT-ID/DemoApplicationQueue
export DEMO_APP_BUCKET_NAME=demo-application-test-bucket-1092734-YOUR-BUCKET-REPLACE-ME
export AWS_CODEGURU_TARGET_REGION=YOUR-AWS-REGION
# Run the demo!
export AWS_CODEGURU_PROFILER_GROUP_NAME=DemoApplication-WithIssues
mvn clean install # generates the DemoApplication-1.0-jar-with-dependencies.jar
java -javaagent:codeguru-profiler-java-agent-standalone-1.0.0.jar \
-jar target/DemoApplication-1.0-jar-with-dependencies.jar with-issues
- To run the
without-issues
version, use the following instructions. Remember to replaceYOUR-ACCOUNT-ID
,YOUR-AWS-REGION
andYOUR-BUCKET-REPLACE-ME
as appropriate.
# These need to be set according to your setup:
export DEMO_APP_SQS_URL=https://sqs.YOUR-AWS-REGION.amazonaws.com/YOUR-ACCOUNT-ID/DemoApplicationQueue
export DEMO_APP_BUCKET_NAME=demo-application-test-bucket-1092734-YOUR-BUCKET-REPLACE-ME
export AWS_CODEGURU_TARGET_REGION=YOUR-AWS-REGION
# Run the demo!
export AWS_CODEGURU_PROFILER_GROUP_NAME=DemoApplication-WithoutIssues
mvn clean install # generates the DemoApplication-1.0-jar-with-dependencies.jar
java -javaagent:codeguru-profiler-java-agent-standalone-1.0.0.jar \
-jar target/DemoApplication-1.0-jar-with-dependencies.jar without-issues
Run this for a few hours to get plenty of data, along with a recommendations report.
Note: When running with-issues
, you'll see plenty of Expensive exception
, Pointless work
and other debug
gibberish being logged. This is expected! This is an example of a badly coded application, and you'll be able to see
how these issues show up on the CodeGuru Profiler console.
So don't worry 😎 -- we totally know about it.
This code is licensed under the MIT-0 License. See the LICENSE file.