0
0
GCPcloud~20 mins

HTTP triggered functions in GCP - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
HTTP Cloud Functions Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
service_behavior
intermediate
2:00remaining
HTTP Function Response Behavior

You deploy a Google Cloud Function triggered by HTTP. The function code is:

def hello_world(request):
    return 'Hello, World!'

What will the HTTP client receive as the response body?

GCP
def hello_world(request):
    return 'Hello, World!'
AThe client receives an empty response with status code 204 (No Content).
BThe client receives a JSON response with body '"Hello, World!"' and status code 200.
CThe client receives a plain text response with body 'Hello, World!' and status code 200.
DThe function raises an error because the return type is incorrect.
Attempts:
2 left
💡 Hint

Consider what happens when a string is returned directly from a Cloud Function.

Configuration
intermediate
2:00remaining
Setting HTTP Trigger Permissions

You want your HTTP triggered Cloud Function to be publicly accessible without authentication. Which IAM role should you grant to allUsers on the function?

Aroles/cloudfunctions.invoker
Broles/cloudfunctions.admin
Croles/viewer
Droles/owner
Attempts:
2 left
💡 Hint

Think about the minimal permission needed to invoke a Cloud Function.

Architecture
advanced
2:00remaining
Designing Scalable HTTP Cloud Functions

You expect a sudden spike of HTTP requests to your Cloud Function. Which design choice helps ensure your function scales smoothly without cold start delays?

AKeep the function stateless and use minimum dependencies to reduce cold start time.
BStore session data in local memory inside the function instance.
CUse a single global variable to cache data across requests.
DIncrease the function timeout to handle longer requests.
Attempts:
2 left
💡 Hint

Consider what causes cold starts and how to minimize their impact.

security
advanced
2:00remaining
Securing HTTP Cloud Functions with Authentication

You want to restrict your HTTP Cloud Function so only authenticated users from your Google Workspace domain can invoke it. What is the best approach?

AGrant roles/cloudfunctions.invoker to allUsers and rely on IP filtering.
BMake the function public and check the user's email in the request headers.
CDisable authentication and rely on a secret token passed as a query parameter.
DRequire users to authenticate with Identity Platform and verify their ID token in the function code.
Attempts:
2 left
💡 Hint

Think about secure ways to verify user identity in Cloud Functions.

Best Practice
expert
2:00remaining
Optimizing HTTP Cloud Function Cold Start Time

You notice your HTTP Cloud Function has high cold start latency due to large dependencies. Which option will most effectively reduce cold start time?

AIncrease the function memory allocation to maximum to speed up startup.
BUse Cloud Functions Gen 2 with container-based deployment and optimize the container image size.
CAdd a warm-up HTTP request every minute to keep the function instance alive.
DRewrite the function in a slower language to reduce startup overhead.
Attempts:
2 left
💡 Hint

Consider newer Cloud Functions platforms and deployment methods.