0
0
Firebasecloud~20 mins

Cloud Functions setup in Firebase - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Cloud Functions Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
service_behavior
intermediate
2:00remaining
Cloud Function Trigger Behavior
You deploy a Firebase Cloud Function triggered by Firestore document creation in the 'orders' collection. What happens when a new document is added to 'orders'?
AThe function runs continuously as long as there is at least one document in 'orders'.
BThe function runs once for every update to any document in 'orders'.
CThe function runs only once when the first document is added to 'orders'.
DThe function runs once for each new document added to 'orders'.
Attempts:
2 left
💡 Hint
Think about what triggers a Firestore onCreate function.
Configuration
intermediate
2:00remaining
Correct Firebase Function Initialization
Which code snippet correctly initializes a Firebase Cloud Function to respond to HTTP requests?
A
const functions = require('firebase-functions');
exports.myFunc = functions.https.onRequest((req, res) => { res.send('Hello'); });
B
const functions = require('firebase-functions');
exports.myFunc = functions.firestore.document('path').onWrite((change, context) => { /* ... */ });
C
const functions = require('firebase-functions');
exports.myFunc = functions.database.ref('path').onWrite((change, context) => { /* ... */ });
D
const functions = require('firebase-functions');
exports.myFunc = functions.storage.object().onFinalize((object) => { /* ... */ });
Attempts:
2 left
💡 Hint
Check which Firebase function type supports HTTP triggers.
Architecture
advanced
3:00remaining
Designing Scalable Cloud Functions
You want to design a Firebase Cloud Function that processes image uploads to Cloud Storage and scales efficiently under heavy load. Which approach is best?
AUse a Cloud Function triggered on image upload that places a message in a Pub/Sub queue for asynchronous processing.
BUse a single Cloud Function triggered on every image upload that processes the image synchronously.
CUse a Cloud Function triggered on HTTP requests to process images uploaded manually by users.
DUse a Cloud Function triggered on Firestore writes to track image uploads and process images in the function.
Attempts:
2 left
💡 Hint
Think about decoupling processing from upload to handle spikes.
security
advanced
3:00remaining
Securing Firebase Cloud Functions
Which practice best secures a Firebase Cloud Function that handles sensitive user data via HTTP requests?
AUse HTTP Basic Authentication with hardcoded credentials in the function.
BAllow all requests and rely on Firestore security rules to protect data.
CRequire Firebase Authentication tokens and verify them inside the function before processing.
DMake the function public and encrypt data only after processing.
Attempts:
2 left
💡 Hint
Think about verifying the identity of the caller before processing sensitive data.
Best Practice
expert
3:00remaining
Optimizing Cold Start Times in Cloud Functions
You notice your Firebase Cloud Functions have high cold start latency. Which option is the best way to reduce cold start times?
AIncrease the memory allocation to the maximum allowed for all functions.
BKeep function code minimal and avoid importing large libraries unless needed.
CDeploy all functions in a single file to reduce deployment size.
DUse synchronous blocking code to ensure all initialization completes before handling requests.
Attempts:
2 left
💡 Hint
Think about what affects the time it takes to start a function instance.