Challenge 4: Improve performance
Previous Challenge Next Challenge
Introduction
You’ve fixed a major problem, but your work isn’t done yet. Users are complaining that the chat experience is slow. Let’s see if we can find the root cause of this issue.
Description
Inspect the performance of the MovieGuru app using Firebase Genkit Monitoring.
- Analyze feature latency: Check P50 and P90 latency for the chatFlow feature. Interpret what these metrics indicate about typical and worst-case performance.
- Inspect trace spans: Inspect traces and analyze individual spans (stages) within the chatFlow. Identify the longest-running spans.
- Pinpoint bottlenecks: Pinpoint which spans are the primary performance bottlenecks.
- Optimize: Identify one specific way to improve overall latency for the flow.
- Implement & Test: Implement your optimization in the code and restart your app.
Optional: Genkit provides local tooling called the Developer UI to help you iterate on prompts and flows more quickly during the development process. See the learning resources below to give it a try.
Success criteria
- You found a span that is much slower than its peers and are able to interpret what the P50 and P90 are telling you.
- You examined and tested out potential fixes (maybe using the Genkit Developer UI).
- You applied the fix in the code and redeployed the app.
- Interactions with the updated app are faster.
Tips
- Model interactions usually will take the bulk of execution time and bigger models will take longer to respond. How long are we spending waiting for the model and what models are we using?
-
Genkit Developer UI: Testing locally with the Genkit Developer UI can help you iterate more quickly on prompts and flows. If you want to set this up, follow the instructions below:
- Navigate in the terminal to the flows folder.
-
Run the following command
cd movie-guru/js/flows npm install . npx genkit start -- npm run dev
- Navigate to http://localhost:4000 (using the WebPreview feature of cloudshell).
- Change the code. Then, use the Genkit developer UI to run the flow locally and verify the change.
Note: Changes made directly within the Genkit Developer UI (like editing model parameters for) are ephemeral for that test-run only and do not save back to your source code files, or effect the flows the use those prompts. Make sure to save your actual code changes in your code editor and restart the Genkit Developer UI and application.