Capacity planning and pricing tiers in No-Code - Time & Space Complexity
Start learning this pattern below
Jump into concepts and practice - no test required
When planning capacity and pricing tiers, it's important to understand how costs and resources grow as more users or data are added.
We want to know how the effort or cost changes when the number of customers or usage increases.
Analyze the time complexity of this simple pricing calculation:
function calculatePrice(users) {
let basePrice = 10;
let totalPrice = basePrice;
if (users > 100) {
totalPrice += (users - 100) * 0.1;
}
return totalPrice;
}
This code calculates the price based on the number of users, adding extra cost for users above 100.
Look for repeated steps that grow with input size.
- Primary operation: A simple calculation based on the number of users above 100.
- How many times: The calculation happens once, no loops or repeated steps.
The calculation does not repeat for each user; it just uses the number to compute the price.
| Input Size (users) | Approx. Operations |
|---|---|
| 10 | 3 operations |
| 100 | 3 operations |
| 1000 | 3 operations |
Pattern observation: The number of operations stays the same no matter how many users there are.
Time Complexity: O(1)
This means the calculation takes the same amount of time no matter how many users you have.
[X] Wrong: "The price calculation takes longer as the number of users grows because it must check each user."
[OK] Correct: The code does not loop through users; it uses a simple math formula, so time does not increase with users.
Understanding how pricing calculations scale helps you design systems that stay efficient as they grow, a key skill in many roles.
What if the pricing calculation included a loop that applied discounts to each user individually? How would the time complexity change?
Practice
Solution
Step 1: Understand capacity planning
Capacity planning is about matching resources like staff, equipment, or space to what customers need.Step 2: Identify the main goal
The goal is to avoid having too few or too many resources, so customers get good service without waste.Final Answer:
To ensure resources meet customer demand -> Option AQuick Check:
Capacity planning = matching resources to demand [OK]
- Confusing capacity planning with pricing
- Thinking it is about marketing
- Assuming it means hiring without planning
Solution
Step 1: Define pricing tiers
Pricing tiers are set levels of prices that vary by usage, features, or customer type.Step 2: Identify the correct feature
They offer clear choices so customers can pick what fits their needs and budget.Final Answer:
Clear levels based on usage or features -> Option CQuick Check:
Pricing tiers = clear levels by usage/features [OK]
- Thinking pricing tiers are random
- Believing there is only one price
- Assuming prices change unpredictably
Solution
Step 1: Identify the tier used
The customer uses features in the Standard tier, which costs $20.Step 2: Match usage to price
Customers pay for the tier that covers their usage, so $20 applies here.Final Answer:
$20 -> Option BQuick Check:
Usage in Standard tier = pay $20 [OK]
- Choosing the lower Basic price
- Assuming Premium price applies always
- Thinking no payment is needed
Solution
Step 1: Compare planned capacity and expected users
The plan is for 100 users but 150 are expected, so capacity is less than demand.Step 2: Understand consequences of undercapacity
Undercapacity means resources are insufficient, causing delays or poor service.Final Answer:
Undercapacity causing poor customer experience -> Option DQuick Check:
Capacity < demand = poor experience [OK]
- Thinking overcapacity is the problem here
- Assuming no effect on quality
- Believing capacity matches demand
Solution
Step 1: Identify customer storage need
The customer needs 60GB of storage.Step 2: Match need to tier capacity
Tier 1 (10GB) and Tier 2 (50GB) are too small; only Tier 3 (100GB) covers 60GB.Step 3: Choose the correct tier
The customer must pick Tier 3 to have enough storage, even if it costs more.Final Answer:
Tier 3, because it covers 100GB needed -> Option AQuick Check:
Need 60GB -> choose tier ≥ 60GB [OK]
- Choosing cheapest tier without enough capacity
- Picking tier that is too small
- Thinking exact match is required
