0
0
GCPcloud~30 mins

Cloud Functions pricing in GCP - Mini Project: Build & Apply

Choose your learning style9 modes available
Understanding Cloud Functions Pricing on GCP
📖 Scenario: You are working as a cloud engineer for a small startup. Your team wants to use Google Cloud Functions to run small pieces of code in response to events. To plan the budget, you need to understand how Cloud Functions pricing works.
🎯 Goal: Build a simple data structure that models Cloud Functions pricing components, then calculate the estimated monthly cost for a given usage scenario.
📋 What You'll Learn
Create a dictionary with exact pricing values for Cloud Functions usage.
Add a variable for the number of function invocations per month.
Calculate the total cost based on invocations and compute time.
Add the final cost calculation including free tier deductions.
💡 Why This Matters
🌍 Real World
Cloud engineers and developers use pricing models to estimate costs before deploying serverless functions.
💼 Career
Understanding pricing helps in budgeting, cost optimization, and communicating costs to stakeholders.
Progress0 / 4 steps
1
Create the Cloud Functions pricing dictionary
Create a dictionary called pricing with these exact entries: 'invocation_cost_per_million': 0.40, 'compute_cost_per_gb_second': 0.0000025, 'free_invocations_per_month': 2000000, and 'free_gb_seconds_per_month': 400000.
GCP
Need a hint?

Use a dictionary with the exact keys and values given.

2
Set the monthly usage variables
Create two variables: monthly_invocations set to 5000000 and monthly_gb_seconds set to 600000 representing the usage for the month.
GCP
Need a hint?

Use the exact variable names and values given.

3
Calculate billable usage after free tier
Create two variables: billable_invocations and billable_gb_seconds. Calculate them by subtracting the free tier values from monthly_invocations and monthly_gb_seconds respectively. If the result is negative, set the value to zero.
GCP
Need a hint?

Use subtraction and if statements to ensure no negative values.

4
Calculate the total monthly cost
Create a variable called total_cost. Calculate it by multiplying billable_invocations divided by 1,000,000 by pricing['invocation_cost_per_million'], then adding the product of billable_gb_seconds and pricing['compute_cost_per_gb_second'].
GCP
Need a hint?

Use arithmetic operations to calculate the total cost.