Bird
0
0

Given this Flask-SQLAlchemy setup:

medium📝 Predict Output Q4 of 15
Flask - Performance Optimization
Given this Flask-SQLAlchemy setup:
app.config['SQLALCHEMY_POOL_SIZE'] = 3
app.config['SQLALCHEMY_POOL_TIMEOUT'] = 5
What happens if 4 simultaneous requests try to use the database?
AThe 4th request waits up to 5 seconds for a connection to free
BThe 4th request immediately creates a new connection
CThe 4th request fails with a timeout error instantly
DAll 4 requests share the same connection simultaneously
Step-by-Step Solution
Solution:
  1. Step 1: Understand pool size and timeout meaning

    Pool size 3 means max 3 connections; timeout 5 means wait 5 seconds for free connection.
  2. Step 2: Analyze behavior on 4th request

    The 4th request waits up to 5 seconds for a connection to become available before failing.
  3. Final Answer:

    The 4th request waits up to 5 seconds for a connection to free -> Option A
  4. Quick Check:

    Pool timeout = wait for free connection [OK]
Quick Trick: Extra requests wait up to pool timeout for connection [OK]
Common Mistakes:
MISTAKES
  • Assuming new connections are created beyond pool size
  • Thinking timeout causes instant failure
  • Believing connections are shared simultaneously

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes