0
0
GCPcloud~10 mins

Cloud Functions pricing in GCP - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Cloud Functions pricing
Function Triggered
Count Invocations
Measure Execution Time
Calculate Memory Used
Apply Free Tier Credits
Calculate Cost
Bill User
When a cloud function runs, GCP counts how many times it runs, how long it runs, and how much memory it uses. Then it subtracts free usage and calculates the cost.
Execution Sample
GCP
Trigger function
Count invocation = 1
Execution time = 200ms
Memory used = 256MB
Calculate cost
Apply free tier
Bill user
This traces a single function execution and how pricing is calculated step-by-step.
Process Table
StepActionValueCalculationResult
1Function triggeredInvocation count +1Invocation count = 1Invocation count = 1
2Measure execution time200 msExecution time = 200 msExecution time = 200 ms
3Measure memory used256 MBMemory used = 256 MBMemory used = 256 MB
4Calculate GB-seconds0.2 sec * 0.256 GB0.0512 GB-seconds0.0512 GB-seconds
5Apply free tierFree 2 million invocations, 400,000 GB-secondsNo cost for this invocationCost = $0
6Calculate costInvocation cost + compute cost0 invocations charged, 0 compute chargedTotal cost = $0
7Bill userTotal costCharge $0 for this invocationUser billed $0
💡 Free tier covers this invocation, so no cost is charged.
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4After Step 5Final
Invocation count0111111
Execution time (sec)000.20.20.20.20.2
Memory used (GB)0000.2560.2560.2560.256
GB-seconds00000.05120.05120.0512
Cost ($)0000000
Key Moments - 2 Insights
Why is the cost zero even though the function ran?
Because the free tier covers 2 million invocations and 400,000 GB-seconds, this single invocation is free as shown in step 5 of the execution table.
How is GB-seconds calculated?
GB-seconds is execution time in seconds multiplied by memory used in GB, as shown in step 4 where 0.2 seconds * 0.256 GB = 0.0512 GB-seconds.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the invocation count after step 1?
A2
B0
C1
D256
💡 Hint
Check the 'Invocation count' variable in the execution_table row for step 1.
At which step is the free tier applied to reduce cost?
AStep 3
BStep 5
CStep 2
DStep 7
💡 Hint
Look for the step mentioning 'Apply free tier' in the execution_table.
If the execution time doubled, how would the GB-seconds value change at step 4?
AIt would double
BIt would halve
CIt would stay the same
DIt would be zero
💡 Hint
GB-seconds = execution time * memory used, so doubling time doubles GB-seconds (see variable_tracker).
Concept Snapshot
Cloud Functions pricing counts how many times your function runs (invocations), how long it runs (execution time), and how much memory it uses.
Pricing is based on GB-seconds (memory * time) and number of invocations.
Google Cloud offers a free tier: 2 million invocations and 400,000 GB-seconds free each month.
Costs apply only after free tier is exceeded.
Billing happens after calculating usage minus free tier credits.
Full Transcript
When you run a Cloud Function, Google Cloud counts how many times it runs, how long it runs, and how much memory it uses. It multiplies execution time by memory to get GB-seconds. Then it subtracts the free tier amounts. If your usage is within free limits, you pay nothing. Otherwise, you pay for extra invocations and GB-seconds. This example shows a function running once for 200 milliseconds using 256 MB memory. The free tier covers this usage, so the cost is zero. The key steps are counting invocations, measuring time and memory, calculating GB-seconds, applying free tier, and billing the user.