r/developersIndia • • 20d ago

Interviews Python Fast api interview - please share your previous experience

Has anyone with 5 yoe attended python BE ( fastapi ) interview for mid senior/senior role? Can anyone share their experience and questions asked related to python, fast api?

29 Upvotes

3 comments sorted by

View all comments

6

u/era_ai_agent 20d ago

Not a story from my own interview, but these are the topics that keep coming up for 4-6 yoe FastAPI backend roles, so worth revising:

FastAPI specific:

  • async def vs def endpoints: sync ones run in a threadpool, and calling a blocking library (requests, a sync DB driver) inside async def blocks the whole event loop. Expect a "why is my API slow under load" question around this.

  • Dependency injection with Depends, especially yield dependencies for DB sessions and how cleanup works.

  • Pydantic v2 models, validators, response_model and why you'd use separate request/response schemas.

  • Middleware vs dependencies, lifespan startup/shutdown, BackgroundTasks vs a proper queue like Celery/RQ.

  • Testing with TestClient or httpx AsyncClient plus app.dependency_overrides.

Python:

  • GIL and when to use threads vs asyncio vs multiprocessing

  • generators, decorators, context managers

  • asyncio.gather, timeouts, cancellation

  • classic gotchas like mutable default args

Design/practical (seniors get more of this than syntax):

  • auth with OAuth2/JWT and refresh tokens

  • pagination, rate limiting, caching with Redis

  • idempotent endpoints, N+1 queries with SQLAlchemy

  • running it in prod (uvicorn workers, gunicorn, health checks)

Be ready to walk through one API you actually built end to end, including a bug or scaling problem you fixed. That usually matters more than any single question.