0
0
Firebasecloud~20 mins

Function deployment in Firebase - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Firebase Function Deployment Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
service_behavior
intermediate
2:00remaining
What happens when you deploy a Firebase function with a syntax error?

You write a Firebase Cloud Function and deploy it using firebase deploy --only functions. The function code contains a syntax error. What will be the result?

Firebase
exports.helloWorld = functions.https.onRequest((req, res) => { res.send('Hello World'); }); // missing closing parenthesis fixed
AThe deployment fails with an error message indicating a syntax error.
BThe function deploys successfully but throws an error only when triggered.
CFirebase automatically fixes the syntax error and deploys the function.
DThe deployment succeeds but the function returns an empty response.
Attempts:
2 left
💡 Hint

Think about what happens if code cannot be parsed correctly before deployment.

Architecture
intermediate
2:00remaining
How to deploy multiple Firebase functions efficiently?

You have three Firebase functions in your project. You want to deploy only two of them without affecting the third. Which command should you use?

Afirebase deploy --only functions:functionOne,functions:functionTwo
Bfirebase deploy --only functionOne,functionTwo
Cfirebase deploy --functions functionOne functionTwo
Dfirebase deploy --only functions
Attempts:
2 left
💡 Hint

Check the syntax for deploying specific functions using the Firebase CLI.

security
advanced
2:00remaining
What is the best practice to secure environment variables in Firebase functions?

You want to store API keys securely for your Firebase functions. Which method ensures the keys are not exposed in your code or public repositories?

AStore keys in <code>.env</code> files and commit them to the repository.
BHardcode the keys directly in the function source code.
CUse Firebase functions config variables with <code>firebase functions:config:set</code> and access them in code.
DStore keys in a public JSON file and fetch them at runtime.
Attempts:
2 left
💡 Hint

Think about how to keep secrets out of source code and public repos.

Best Practice
advanced
2:00remaining
How to minimize cold start latency in Firebase functions?

You notice your Firebase functions have slow response times on the first request after deployment or inactivity. What is a recommended approach to reduce this cold start delay?

ADeploy all functions in a single large file to reduce deployment size.
BKeep functions small and avoid heavy initialization code outside the handler.
CUse synchronous blocking code to ensure all setup completes before responding.
DDisable function scaling to keep instances always warm.
Attempts:
2 left
💡 Hint

Think about what causes cold start delays in serverless functions.

🧠 Conceptual
expert
2:00remaining
What is the effect of setting maxInstances in Firebase function deployment?

You configure a Firebase function with maxInstances: 2. What behavior does this setting enforce?

Firebase
exports.limitedFunction = functions.runWith({ maxInstances: 2 }).https.onRequest((req, res) => { res.send('Hello'); });
AEnsures the function always runs on exactly 2 instances regardless of traffic.
BAllows unlimited instances but restricts each instance to 2 concurrent requests.
CLimits the function to handle only 2 requests total before shutting down.
DLimits the function to run on at most 2 instances simultaneously, controlling concurrency and cost.
Attempts:
2 left
💡 Hint

Consider what maxInstances controls in serverless scaling.