0
0
AWScloud~5 mins

Creating a Lambda function in AWS - Performance & Efficiency

Choose your learning style9 modes available
Time Complexity: Creating a Lambda function
O(n)
Understanding Time Complexity

When creating a Lambda function, it's important to understand how the time to complete the setup grows as you add more resources or configurations.

We want to know how the number of steps or API calls changes as we create more Lambda functions.

Scenario Under Consideration

Analyze the time complexity of the following operation sequence.


# Create a Lambda function
aws lambda create-function \
  --function-name MyFunction \
  --runtime python3.12 \
  --role arn:aws:iam::123456789012:role/lambda-role \
  --handler lambda_function.lambda_handler \
  --zip-file fileb://function.zip
    

This sequence creates one Lambda function with specified runtime, role, handler, and code package.

Identify Repeating Operations

Identify the API calls, resource provisioning, data transfers that repeat.

  • Primary operation: The create-function API call to provision a Lambda function.
  • How many times: Once per Lambda function created.
How Execution Grows With Input

Each Lambda function requires one API call to create it, so the total calls grow directly with the number of functions.

Input Size (n)Approx. Api Calls/Operations
1010
100100
10001000

Pattern observation: The number of API calls increases one-to-one with the number of Lambda functions created.

Final Time Complexity

Time Complexity: O(n)

This means the time to create Lambda functions grows linearly with how many you create.

Common Mistake

[X] Wrong: "Creating multiple Lambda functions can be done with a single API call, so time stays the same."

[OK] Correct: Each Lambda function requires its own create call; there is no batch create API, so time grows with the number of functions.

Interview Connect

Understanding how API calls scale when creating cloud resources shows you can plan for growth and manage deployment time effectively.

Self-Check

"What if we used a deployment tool that creates multiple Lambda functions in parallel? How would the time complexity change?"