Bird
Raised Fist0
GCPcloud~20 mins

Cloud Functions pricing in GCP - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Cloud Functions Pricing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Cloud Functions invocation pricing

Google Cloud Functions charges based on the number of function invocations. Suppose you have a function that is triggered 1,000,000 times in a month. The first 2 million invocations are free each month. How much will you be charged for invocations?

AYou will not be charged because 1,000,000 is less than the free 2 million invocations.
BYou will be charged for all 1,000,000 invocations.
CYou will be charged only for 500,000 invocations.
DYou will be charged a flat monthly fee regardless of invocations.
Attempts:
2 left
💡 Hint

Remember the free tier covers the first 2 million invocations per month.

❓ service_behavior
intermediate
2:00remaining
Effect of function memory size on billing

You deploy a Cloud Function with 256 MB memory and it runs for 2 seconds per invocation. You then change the memory to 512 MB but the function runtime stays the same. How does this affect your billing?

ABilling cost halves because more memory means faster execution.
BBilling cost stays the same because runtime did not change.
CBilling cost doubles because memory doubled, even though runtime is the same.
DBilling cost is based only on number of invocations, so no change.
Attempts:
2 left
💡 Hint

Billing depends on memory size and execution time together.

❓ Architecture
advanced
2:00remaining
Optimizing Cloud Functions cost for high CPU usage

You have a Cloud Function that performs CPU-intensive tasks and runs for 5 seconds with 256 MB memory. You want to reduce cost and improve performance. Which approach is best?

AIncrease memory to 1 GB to get more CPU power and reduce runtime.
BDecrease memory to 128 MB to save cost, even if runtime increases.
CKeep memory at 256 MB and reduce number of invocations.
DSwitch to a different cloud service that charges per CPU second.
Attempts:
2 left
💡 Hint

More memory means more CPU power in Cloud Functions.

❓ security
advanced
2:00remaining
Impact of Cloud Functions pricing on security design

You want to secure a Cloud Function that processes sensitive data. You add logging for every invocation, which increases execution time by 1 second. How does this affect your Cloud Functions pricing?

ACost increases only if logs are stored in Cloud Storage.
BCost increases because billing is based on execution time including logging overhead.
CCost decreases because logging optimizes function performance.
DCost stays the same because logging is free and does not affect billing.
Attempts:
2 left
💡 Hint

Execution time includes all code running inside the function.

✅ Best Practice
expert
2:00remaining
Choosing Cloud Functions region for cost efficiency

You deploy identical Cloud Functions in two different regions: Region A charges $0.0000025 per GB-second and Region B charges $0.0000030 per GB-second. Both have the same free tier. You expect 10 million GB-seconds usage monthly. Which region is more cost-effective and why?

ARegion B is more cost-effective because it has better network latency.
BRegion B is cheaper because it offers discounts for high usage.
CBoth regions cost the same because free tier covers all usage.
DRegion A is more cost-effective because it has a lower GB-second price.
Attempts:
2 left
💡 Hint

Compare price per GB-second after free tier.

Practice

(1/5)
1. What are the main factors that determine the cost of Google Cloud Functions?
easy
A. Number of API calls, database queries, and cache hits
B. Number of invocations, compute time, and outbound data
C. CPU type, memory size, and disk I/O
D. Number of users, storage size, and network speed

Solution

  1. Step 1: Identify pricing components

    Google Cloud Functions pricing is based on how many times functions run (invocations), how long they run (compute time), and how much data they send out (outbound data).
  2. Step 2: Match factors to options

    Number of invocations, compute time, and outbound data lists these exact factors, while others mention unrelated metrics like users or storage.
  3. Final Answer:

    Number of invocations, compute time, and outbound data -> Option B
  4. Quick Check:

    Pricing factors = invocations, compute time, outbound data [OK]
Hint: Remember: cost depends on usage, not users or storage [OK]
Common Mistakes:
  • Confusing storage or users with function pricing
  • Thinking CPU type alone affects cost
  • Mixing up inbound and outbound data charges
2. Which of the following is the correct way to describe the free tier for Google Cloud Functions?
easy
A. It offers unlimited invocations and compute time for all users
B. It charges a small fee for every invocation regardless of usage
C. It provides a fixed number of free invocations and compute time each month
D. It only applies to functions running in specific regions

Solution

  1. Step 1: Understand free tier basics

    The free tier gives a set amount of free invocations and compute time monthly, not unlimited usage.
  2. Step 2: Compare options

    It provides a fixed number of free invocations and compute time each month correctly states the free tier provides fixed free usage. It offers unlimited invocations and compute time for all users is wrong because it says unlimited. It charges a small fee for every invocation regardless of usage is wrong because free tier means no charge up to limits. It only applies to functions running in specific regions is incorrect as free tier applies globally.
  3. Final Answer:

    It provides a fixed number of free invocations and compute time each month -> Option C
  4. Quick Check:

    Free tier = fixed free usage monthly [OK]
Hint: Free tier means limited free usage, not unlimited [OK]
Common Mistakes:
  • Assuming free tier is unlimited
  • Thinking free tier applies only in some regions
  • Believing every invocation is charged
3. A Cloud Function runs 1,000,000 times in a month, each execution lasting 200 milliseconds with 256 MB memory allocated. Which factor primarily affects the compute time cost?
medium
A. Number of invocations only
B. Outbound data volume
C. Function trigger type
D. Execution duration and memory size

Solution

  1. Step 1: Identify compute time cost factors

    Compute time cost depends on how long the function runs and how much memory it uses during execution.
  2. Step 2: Analyze options

    Execution duration and memory size correctly identifies execution duration and memory size as key for compute cost. Invocations count affects invocation cost, not compute time alone. Outbound data and trigger type do not affect compute time cost.
  3. Final Answer:

    Execution duration and memory size -> Option D
  4. Quick Check:

    Compute cost = duration x memory [OK]
Hint: Compute cost = run time x memory size [OK]
Common Mistakes:
  • Confusing invocation count with compute time cost
  • Ignoring memory size in cost calculation
  • Thinking trigger type affects compute cost
4. You notice your Cloud Function costs are unexpectedly high. Which of the following is the most likely cause?
medium
A. Function runs longer than expected or uses more memory
B. You exceeded the free tier for outbound data only
C. You deployed the function in multiple regions accidentally
D. You used a deprecated runtime version

Solution

  1. Step 1: Identify common cost drivers

    High costs usually come from functions running longer or using more memory, increasing compute time charges.
  2. Step 2: Evaluate other options

    You exceeded the free tier for outbound data only is less likely since outbound data is often smaller cost. You deployed the function in multiple regions accidentally might increase cost but is less common. You used a deprecated runtime version affects functionality, not pricing directly.
  3. Final Answer:

    Function runs longer than expected or uses more memory -> Option A
  4. Quick Check:

    Longer run or more memory = higher cost [OK]
Hint: Check function duration and memory to find cost spikes [OK]
Common Mistakes:
  • Blaming deprecated runtime for cost increase
  • Ignoring function execution time impact
  • Assuming outbound data is main cost driver
5. You want to optimize costs for a Cloud Function that processes large files and sends results over the network. Which combination of strategies will most effectively reduce your bill?
hard
A. Reduce function memory allocation and minimize outbound data size
B. Increase function timeout and add more retries
C. Deploy multiple identical functions in different regions
D. Use a higher memory allocation to speed up execution regardless of data size

Solution

  1. Step 1: Identify cost factors for large file processing

    Costs come from compute time (affected by memory and duration) and outbound data size.
  2. Step 2: Evaluate optimization strategies

    Reducing memory allocation lowers compute cost if performance is sufficient. Minimizing outbound data reduces network charges. Increasing timeout or retries raises cost. Deploying multiple functions increases cost. Higher memory may speed execution but can increase cost if not balanced.
  3. Final Answer:

    Reduce function memory allocation and minimize outbound data size -> Option A
  4. Quick Check:

    Lower memory + less data = cost savings [OK]
Hint: Cut memory and data size to save costs effectively [OK]
Common Mistakes:
  • Thinking more memory always reduces cost
  • Adding retries without cost consideration
  • Deploying duplicates increases cost unnecessarily
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard