📖 Scenario: You are a cloud architect helping a small company decide how to deploy their new web application on Google Cloud Platform (GCP). They want to understand the difference between using a serverless approach with Cloud Run and using Google Kubernetes Engine (GKE) for container orchestration.Your task is to create a simple decision helper that models the choice between Serverless and GKE based on application needs.
🎯 Goal: Build a Python script that stores application requirements, sets a threshold for complexity, and uses a decision logic to recommend either Serverless (Cloud Run) or GKE deployment.
📋 What You'll Learn
Create a dictionary with exact application requirements and their values
Add a complexity threshold variable
Write a decision logic using an if-else statement to choose between Serverless and GKE
Output the final deployment recommendation as a variable
💡 Why This Matters
🌍 Real World
Cloud architects often need to decide the best deployment method for applications based on their requirements and complexity.
💼 Career
Understanding how to model application needs and make deployment decisions is key for roles in cloud architecture and infrastructure engineering.
Progress0 / 4 steps
1
Create application requirements dictionary
Create a dictionary called app_requirements with these exact entries: 'concurrent_users': 1000, 'cpu_intensive': false, 'requires_scaling': true, 'deployment_complexity': 3
GCP
Hint
Use curly braces to create a dictionary and separate key-value pairs with commas.
2
Set complexity threshold variable
Create a variable called complexity_threshold and set it to 5
GCP
Hint
Assign the number 5 to the variable named complexity_threshold.
3
Write decision logic for deployment choice
Write an if-else statement that checks if app_requirements['deployment_complexity'] is less than complexity_threshold. If true, assign 'Serverless' to a variable called deployment_choice. Otherwise, assign 'GKE' to deployment_choice.
GCP
Hint
Use the if keyword to compare values and assign the correct string to deployment_choice.
4
Add final deployment recommendation variable
Create a variable called final_recommendation and set it equal to deployment_choice
GCP
Hint
Assign the value of deployment_choice to final_recommendation.
Practice
(1/5)
1. Which option best describes a key benefit of using serverless computing in GCP?
easy
A. No need to manage servers and automatic scaling happens
B. You get full control over the underlying hardware
C. You must manually configure load balancers
D. You need to manage container orchestration
Solution
Step 1: Understand serverless basics
Serverless means the cloud provider handles server management and scaling automatically.
Step 2: Compare options
The other options describe manual management or container orchestration, which are not serverless benefits.
Final Answer:
No need to manage servers and automatic scaling happens -> Option A
Quick Check:
Serverless = No server management + auto scaling [OK]
Hint: Serverless means no servers to manage, auto scales itself [OK]
Common Mistakes:
Confusing serverless with container management
Thinking serverless requires manual scaling
Assuming serverless means full hardware control
2. Which of the following is the correct way to deploy a containerized app on GKE?
easy
A. Use gcloud run deploy command
B. Use kubectl apply -f deployment.yaml command
C. Use firebase deploy command
D. Use gsutil cp to upload container image
Solution
Step 1: Identify GKE deployment command
GKE uses Kubernetes commands like kubectl apply to deploy resources from YAML files.
Step 2: Check other commands
gcloud run deploy is for serverless Cloud Run, firebase deploy is for Firebase apps, and gsutil cp uploads files to storage, not deploy containers.
Final Answer:
Use kubectl apply -f deployment.yaml command -> Option B
Quick Check:
GKE deploy = kubectl apply [OK]
Hint: GKE uses kubectl with YAML files to deploy containers [OK]
Common Mistakes:
Using Cloud Run commands for GKE
Confusing Firebase deploy with container deployment
Uploading images with gsutil instead of container registry
3. You have a web app with unpredictable traffic spikes and want minimal management. Which GCP service behavior fits best?
medium
A. Serverless auto-scales instantly with no server management
B. GKE requires manual scaling and cluster management
C. GKE automatically scales without any configuration
D. Serverless requires you to provision VM instances
Solution
Step 1: Analyze traffic and management needs
Unpredictable spikes need fast scaling and minimal management.
Step 2: Match service behavior
Serverless auto-scales instantly and requires no server management. GKE needs manual or configured scaling and cluster upkeep.
Final Answer:
Serverless auto-scales instantly with no server management -> Option A
Hint: Unpredictable traffic? Choose serverless for auto scaling [OK]
Common Mistakes:
Assuming GKE scales automatically without config
Thinking serverless needs VM provisioning
Confusing manual and automatic scaling
4. You deployed a container on GKE but it fails to start. Which fix is most likely needed?
medium
A. Enable serverless API in GCP console
B. Increase Cloud Run memory allocation
C. Check and fix container image path in deployment YAML
D. Upload container image to Firebase hosting
Solution
Step 1: Identify cause of container start failure
Common cause is incorrect container image path or tag in deployment YAML.
Step 2: Evaluate options
Increasing Cloud Run memory or enabling serverless API does not affect GKE container start. Firebase hosting is unrelated to container images.
Final Answer:
Check and fix container image path in deployment YAML -> Option C
Quick Check:
Container start fail? Fix image path in YAML [OK]
Hint: Check container image path in YAML if GKE pod fails [OK]
Common Mistakes:
Trying serverless fixes for GKE issues
Uploading images to wrong services
Ignoring deployment YAML errors
5. Your app needs custom networking, persistent storage, and runs long background jobs. Which GCP choice fits best?
hard
A. Use serverless Cloud Run for easy scaling and no management
B. Use Firebase hosting for backend processing
C. Use App Engine standard environment for background jobs
D. Use GKE for full control over networking and storage
Solution
Step 1: Identify app requirements
Custom networking, persistent storage, and long background jobs require control and flexibility.
Step 2: Match requirements to GCP services
GKE offers container orchestration with networking and storage control. Serverless Cloud Run lacks persistent storage and complex networking. App Engine standard has limitations on background jobs. Firebase hosting is for static content.
Final Answer:
Use GKE for full control over networking and storage -> Option D
Quick Check:
Custom network + storage + long jobs = GKE [OK]
Hint: Need control and storage? Choose GKE over serverless [OK]
Common Mistakes:
Choosing serverless despite storage needs
Using App Engine for heavy background jobs
Confusing Firebase hosting with backend services
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.