FastAPI Cheatsheet 06 — Async, Concurrency, and the Threadpool

Cheatsheet: async def vs def, AnyIO/TaskGroup, to_thread, blocking traps, semaphores, timeouts, cancellation.

May 11, 2026 · 3 min · 430 words · Manvendra Rajpoot

FastAPI Textbook Ch. 6 — Authentication and Authorization

Auth and authz in FastAPI: passwords, JWT, OAuth2 / OIDC, sessions, passkeys, RBAC, scopes, and security best practices.

May 6, 2026 · 6 min · 1129 words · Manvendra Rajpoot

FastAPI Cheatsheet 07 — WebSockets and SSE

Cheatsheet: WebSocket handlers, auth patterns, broadcast (single + multi-process), SSE, NDJSON, heartbeats.

May 11, 2026 · 3 min · 467 words · Manvendra Rajpoot

FastAPI Textbook Ch. 7 — Async, Concurrency, and the Threadpool

Concurrency in FastAPI: async vs sync handlers, the threadpool, AnyIO, blocking traps, structured concurrency, and how to scale.

May 6, 2026 · 5 min · 1033 words · Manvendra Rajpoot

FastAPI Cheatsheet 08 — Background Tasks and Job Queues

Cheatsheet: BackgroundTasks for fire-and-forget, ARQ / Celery / Dramatiq enqueue patterns, idempotency.

May 11, 2026 · 2 min · 416 words · Manvendra Rajpoot

FastAPI Textbook Ch. 8 — WebSockets, SSE, and Streaming Responses

Real-time FastAPI: WebSockets, broadcast / pub-sub, SSE for one-way streams, StreamingResponse, NDJSON, and disconnect handling.

May 6, 2026 · 5 min · 932 words · Manvendra Rajpoot

FastAPI Cheatsheet 09 — Testing with Pytest, AsyncClient, and testcontainers

Cheatsheet: AsyncClient + pytest-anyio, dependency overrides, testcontainers Postgres, factory_boy, OpenAPI tests.

May 11, 2026 · 3 min · 464 words · Manvendra Rajpoot

FastAPI Textbook Ch. 9 — Background Tasks and Task Queues

Background tasks in FastAPI: BackgroundTasks for fire-and-forget, ARQ / Celery / Dramatiq for reliable jobs, scheduling, and long-running operations.

May 6, 2026 · 5 min · 921 words · Manvendra Rajpoot

FastAPI Cheatsheet 10 — Observability: structlog, OTEL, Prometheus

Cheatsheet: structlog with contextvars, OTEL auto-instrumentation, custom spans, Prometheus middleware, /metrics.

May 11, 2026 · 2 min · 395 words · Manvendra Rajpoot

FastAPI Textbook Ch. 10 — Testing FastAPI: Pytest, AnyIO, and Real DBs

Testing FastAPI: TestClient and AsyncClient, dependency overrides, real DB testing with testcontainers, factory fixtures, and CI integration.

May 6, 2026 · 4 min · 762 words · Manvendra Rajpoot