Bird
0
0

You want to optimize a FastAPI app using SQLAlchemy with a PostgreSQL database. The app has many short requests. Which pooling configuration best balances performance and resource use?

hard🚀 Application Q15 of 15
FastAPI - Database Integration
You want to optimize a FastAPI app using SQLAlchemy with a PostgreSQL database. The app has many short requests. Which pooling configuration best balances performance and resource use?
Options:
A) pool_size=20, max_overflow=10
B) pool_size=1, max_overflow=50
C) pool_size=5, max_overflow=0
D) pool_size=0, max_overflow=0
Apool_size=5, max_overflow=0
Bpool_size=1, max_overflow=50
Cpool_size=20, max_overflow=10
Dpool_size=0, max_overflow=0
Step-by-Step Solution
Solution:
  1. Step 1: Understand pool_size and max_overflow roles

    pool_size sets fixed connections; max_overflow allows extra temporary connections beyond pool_size.
  2. Step 2: Analyze options for many short requests

    Too large pool_size wastes resources; too small with high overflow risks overhead. pool_size=5, max_overflow=0 with moderate pool_size=5 and no overflow balances reuse and resource use well.
  3. Final Answer:

    pool_size=5, max_overflow=0 -> Option A
  4. Quick Check:

    Moderate pool_size with no overflow balances performance and resources [OK]
Quick Trick: Moderate pool_size with zero overflow balances well [OK]
Common Mistakes:
MISTAKES
  • Choosing very high pool_size wasting resources
  • Using zero pool_size disables pooling
  • Setting high max_overflow causes many temporary connections

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FastAPI Quizzes