Creating a Lambda function in AWS - Performance & Efficiency
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.
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 the API calls, resource provisioning, data transfers that repeat.
- Primary operation: The
create-functionAPI call to provision a Lambda function. - How many times: Once per Lambda function created.
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 |
|---|---|
| 10 | 10 |
| 100 | 100 |
| 1000 | 1000 |
Pattern observation: The number of API calls increases one-to-one with the number of Lambda functions created.
Time Complexity: O(n)
This means the time to create Lambda functions grows linearly with how many you create.
[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.
Understanding how API calls scale when creating cloud resources shows you can plan for growth and manage deployment time effectively.
"What if we used a deployment tool that creates multiple Lambda functions in parallel? How would the time complexity change?"