0
0
GCPcloud~30 mins

Cloud Run vs Cloud Functions decision in GCP - Hands-On Comparison

Choose your learning style9 modes available
Deciding Between Cloud Run and Cloud Functions on GCP
📖 Scenario: You are working as a cloud engineer for a small company. Your team needs to deploy a new service that processes user requests. You want to choose the right Google Cloud service between Cloud Run and Cloud Functions.Cloud Run lets you run containerized applications that can handle many requests at once. Cloud Functions lets you run small pieces of code that respond to events.
🎯 Goal: Build a simple decision helper using Python that helps decide whether to use Cloud Run or Cloud Functions based on the service requirements.
📋 What You'll Learn
Create a dictionary with service requirements
Add a configuration variable for maximum concurrent requests
Write logic to decide between Cloud Run and Cloud Functions
Output the final decision as a string
💡 Why This Matters
🌍 Real World
Choosing the right cloud service helps optimize cost and performance for deploying applications.
💼 Career
Cloud engineers and developers often decide between serverless functions and containerized services based on workload characteristics.
Progress0 / 4 steps
1
Create service requirements dictionary
Create a dictionary called service_requirements with these exact entries: 'max_requests_per_second': 100, 'needs_container': True, 'event_driven': False
GCP
Need a hint?

Use a Python dictionary with the exact keys and values given.

2
Add max concurrency configuration
Create a variable called max_concurrent_requests and set it to 80
GCP
Need a hint?

This variable will help decide if Cloud Run can handle the load.

3
Write decision logic
Write an if statement that sets a variable decision to 'Cloud Run' if service_requirements['needs_container'] is True or service_requirements['max_requests_per_second'] is greater than max_concurrent_requests. Otherwise, set decision to 'Cloud Functions'
GCP
Need a hint?

Use an if-else block with the exact variable names and conditions.

4
Output the final decision
Add a variable called final_decision and set it equal to the decision variable
GCP
Need a hint?

This variable holds the final choice for deployment service.