Explore Lambda Insights

  1. In the AWS Management Console on the Services menu, click CloudWatch.
  2. In the left navigation menu, click on Lamdba Insights, then Multi-function.

You will see the metrics of the four Lambda functions that were created as part of the PetAdoptions application.

You can view metrics for a specific lambda function by hovering over and clicking on it.

Lambdainsights multi-function

  1. In the drop down at the top with multi-function currently selected, select single-function.

You can see the individual function metrics like CPU, Memory and Network Usage as shown below.

Lambdainsights single-function

Lambda Insights is integrated with ServiceLens. You can view X-Ray traces by clicking on View shown below for a particular function execution.

Lambdainsights x-ray

Lambdainsights x-ray

Rightsizing the Lambda functions

  1. You can see that the memory utilization of all the lambda functions being very high as shown below. This is a clear indication that the lambda needs to be allocated higher memory.

High memory usage

  1. Let’s increase the memory allocation of the statusupdaterservice lambda function to fix this problem. Before we do that, let’s find out the current memory allocation of the lambda function.
LAMBDA_FUNCTION_NAME=$(aws lambda list-functions | jq -r '.Functions[].FunctionName | select(contains("statusupdaterservice"))')

aws lambda get-function-configuration --function-name $LAMBDA_FUNCTION_NAME

You can see the current memory allocation in the result as shown below Current memory allocation

Now execute the following command to increase the memory allocation

aws lambda  update-function-configuration --function-name $LAMBDA_FUNCTION_NAME --memory-size 256
  1. Wait for a few minutes to see the memory utilization drop as shown below.

Lambdainsights memory utilization drop

This concludes the Lambda Insights module.