Bird
0
0

You want to profile only specific routes in your Flask app to reduce overhead. Which approach is best?

hard📝 Conceptual Q8 of 15
Flask - Performance Optimization
You want to profile only specific routes in your Flask app to reduce overhead. Which approach is best?
AWrap only the WSGI app for those routes with ProfilerMiddleware using a custom dispatcher
BEnable ProfilerMiddleware globally and filter output manually
CUse Flask-Security to restrict profiling to certain users
DDisable profiling and rely on logging instead
Step-by-Step Solution
Solution:
  1. Step 1: Understand selective profiling

    Profiling only some routes requires wrapping those routes' WSGI apps selectively.
  2. Step 2: Evaluate options

    Global profiling with manual filtering adds overhead; Flask-Security is unrelated; disabling profiling avoids the goal.
  3. Final Answer:

    Wrap only the WSGI app for those routes with ProfilerMiddleware using a custom dispatcher -> Option A
  4. Quick Check:

    Selectively wrap routes for profiling = Wrap only the WSGI app for those routes with ProfilerMiddleware using a custom dispatcher [OK]
Quick Trick: Use custom WSGI dispatch to profile specific routes only [OK]
Common Mistakes:
MISTAKES
  • Profiling globally and filtering later
  • Confusing security with profiling control
  • Disabling profiling instead of limiting it

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes