Back to feed
Dev.to
Dev.to
7/14/2026
The original title is: "Sync to Async: Migrating FastAPI Endpoints to arq/Redis"

The original title is: "Sync to Async: Migrating FastAPI Endpoints to arq/Redis"

Original: Sync to Async: Migrating FastAPI Endpoints to arq/Redis

Short summary

A practical walkthrough of migrating a synchronous FastAPI PDF ingest endpoint to async using arq and Redis. The author moves OCR and LLM extraction work into an arq background worker, wires the Redis pool via FastAPI's lifespan context manager with best-effort startup, and exposes a clean dependency injection alias for routers. The client polls a status endpoint with the job ID instead of blocking on the request.

  • Sync endpoint blocking for minutes during OCR + LLM extraction replaced with arq job queue and Redis
  • Redis pool initialized in FastAPI lifespan with graceful 503 fallback if Redis is unavailable
  • Clean DI pattern via Annotated alias keeps routers decoupled from infrastructure concerns

Generated with AI, which can make mistakes.

Is this a good recommendation for you?

Comments

Failed to load comments. Please try again.

Explore more